diff --git a/sunrise-commit b/sunrise-commit index 7dd596b..f8f3209 100755 --- a/sunrise-commit +++ b/sunrise-commit @@ -78,11 +78,11 @@ check_for_changes() { local output if [ ${SC_VCS%-svn} = git ]; then - output="$(git diff-index --name-status --relative HEAD)" + output="$(git diff-index --name-only --relative HEAD)" fi - sayv "${output}" - [ -n "${output}" ] + # We do not care about user mangling ChangeLog, we will reset it anyway. + echo "${output}" | grep -v ChangeLog >/dev/null } vcs_reset() { @@ -92,6 +92,12 @@ vcs_reset() { fi } +vcs_status() { + if [ ${SC_VCS%-svn} = git ]; then + git status -s . + fi +} + # Guess what! main() { local commitmsg @@ -125,13 +131,34 @@ main() { # With native git repos, we do not do ChangeLogs by default... # ...at least unless they're already there. - if [ ${SC_VCS} = git -a ! -f ChangeLog ]; then + if [ ${SC_VCS} != git -o -f ChangeLog ]; then sayv 'Cleaning up the ChangeLog...' vcs_reset ChangeLog + + local bns + # Let's take a lucky guess bugnumbers consist of 4+ digits. + bns="$(echo "${commitmsg}" | grep -o -E '[0-9]{4,}')" + + # Creating a new ChangeLog? Let's take a look at the commit message. + [ ! -f ChangeLog -a -z "${bns}" ] && die 'Please supply the bug number in the initial commit message!' + sayv '...and appending to it.' - echangelog "${commitmsg}" + req echangelog "${commitmsg}" + + if [ -n "${bns}" ]; then + echo + local bn + for bn in ${bns}; do + wget -q http://bugs.gentoo.org/show_bug.cgi?id=12345 -O - \ + | sed -e 's; *Gentoo Bug \([0-9]*\) - \(.*\);Bug \1: \2;gp' -e d + done + echo + fi fi + vcs_status + echo + sayv "Now, let's let repoman do its job..." exec repoman commit -a -m "${SC_CP}: ${commitmsg}" ;;