[coreboot] New patch to review: 626e5e0 Un-perl commit-msg hook

Patrick Georgi (patrick@georgi-clan.de) gerrit at coreboot.org
Sat Jul 2 00:36:47 CEST 2011


Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/78

-gerrit

commit 626e5e0018544d599c1c5d7d6797463f4803b756
Author: Patrick Georgi <patrick at 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 at 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.. at 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`"




More information about the coreboot mailing list