Patrick Georgi (patrick@georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/78
-gerrit
commit 6195e48fbe30cf93a53c2aec379534daa1d95582 Author: Patrick Georgi patrick@georgi-clan.de Date: Sat Jul 2 00:35:02 2011 +0200
Un-perl commit-msg hook
To simplify installation on mingw a bit (even though git remains a pain), drop the perl dependency the commit-msg hook introduced to the coreboot development environment. It's replaced by awk which we use elsewhere already (and is a more lightweight utility in any case)
Change-Id: I67adfe1ec43c898735d4bae4819ceb53e83c303b Signed-off-by: Patrick Georgi patrick@georgi-clan.de --- util/gitconfig/commit-msg | 61 ++++++++++++++++++-------------------------- 1 files changed, 25 insertions(+), 36 deletions(-)
diff --git a/util/gitconfig/commit-msg b/util/gitconfig/commit-msg index 789bad3..4c80420 100755 --- a/util/gitconfig/commit-msg +++ b/util/gitconfig/commit-msg @@ -43,46 +43,35 @@ add_ChangeId() { fi
id=`_gen_ChangeId` - perl -e ' - $MSG = shift; - $id = shift; - $CHANGE_ID_AFTER = shift; + T=`mktemp` + cat "$MSG" | awk ' + !/^[a-zA-Z0-9-]+:/ { + print $0; + next; + };
- undef $/; - open(I, $MSG); $_ = <I>; close I; - s|^diff --git a/.*||ms; - s|^#.*$||mg; - exit unless $_; + { + if (lines != "") { + lines = lines "\n"; + }; + lines = lines $0 + };
- @message = split /\n/; - $haveFooter = 0; - $startFooter = @message; - for($line = @message - 1; $line >= 0; $line--) { - $_ = $message[$line]; - - if (/^[a-zA-Z0-9-]+:/ && !m,^[a-z0-9-]+://,) { - $haveFooter++; - next; - } - next if /^[ []/; - $startFooter = $line if ($haveFooter && /^\r?$/); - last; + END { + split(lines, footer, "\n"); + numlines=length(footer); + pre=1; + for (line = 1; line <= numlines; line++) { + if (pre && match(footer[line], "('$CHANGE_ID_AFTER'):") != 1) { + pre=0; + print "Change-Id: I'$id'"; + }; + print footer[line]; } - - @footer = @message[$startFooter+1..@message]; - @message = @message[0..$startFooter]; - push(@footer, "") unless @footer; - - for ($line = 0; $line < @footer; $line++) { - $_ = $footer[$line]; - next if /^($CHANGE_ID_AFTER):/i; - last; + if (pre) { + print "Change-Id: I'$id'"; } - splice(@footer, $line, 0, "Change-Id: I$id"); - - $_ = join("\n", @message, @footer); - open(O, ">$MSG"); print O; close O; - ' "$MSG" "$id" "$CHANGE_ID_AFTER" + }' > $T && mv $T "$MSG" || rm -f $T } _gen_ChangeIdInput() { echo "tree `git write-tree`"