From 3473a15f610a6326d8004dc9218541469eef5e13 Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Mon, 20 Apr 2020 23:53:10 +0000 Subject: [PATCH 1/2] Revert "commit-msg: Remove obsolete comments" This reverts commit 10547261a0c30344f615020d6099cfa48db1ec8a. Reason for revert: Did not fully resolve the Issue 12546 Change-Id: Ibccec851372e5e8429b4366e2dca3d60a5fc666d --- resources/com/google/gerrit/server/tools/root/hooks/commit-msg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/com/google/gerrit/server/tools/root/hooks/commit-msg b/resources/com/google/gerrit/server/tools/root/hooks/commit-msg index 42dbfb99bc..2b1a2fc1c4 100755 --- a/resources/com/google/gerrit/server/tools/root/hooks/commit-msg +++ b/resources/com/google/gerrit/server/tools/root/hooks/commit-msg @@ -48,6 +48,8 @@ if test ! -s "${dest}" ; then exit 1 fi +# Avoid the --in-place option which only appeared in Git 2.8 +# Avoid the --if-exists option which only appeared in Git 2.15 if ! git -c trailer.ifexists=doNothing interpret-trailers --where start \ --trailer "Change-Id: I${random}" < "$1" > "${dest}" ; then echo "cannot insert change-id line in $1" From 79b417265d96c961cf609747e229eacbb23f8d01 Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Mon, 20 Apr 2020 23:53:26 +0000 Subject: [PATCH 2/2] Revert "Insert Change-Id at start of trailers" This reverts commit 2336606fb9fac86a0e74120d33a9b0d8d6bd2042. Reason for revert: Did not fully resolve the Issue 12546 Change-Id: I12e70a65e2fc68767354a066cd3995860a245a3a --- .../com/google/gerrit/server/commit-msg_test.sh | 16 ++++++++-------- .../gerrit/server/tools/root/hooks/commit-msg | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/com/google/gerrit/server/commit-msg_test.sh b/resources/com/google/gerrit/server/commit-msg_test.sh index c016a8925b..d797be30fd 100755 --- a/resources/com/google/gerrit/server/commit-msg_test.sh +++ b/resources/com/google/gerrit/server/commit-msg_test.sh @@ -63,9 +63,9 @@ index 625fd613d9..03aeba3b21 100755 @@ -38,6 +38,7 @@ context line - + +hello, world - + context line EOF @@ -111,7 +111,7 @@ EOF } # Change-Id goes after existing trailers. -function test_at_start { +function test_at_end { cat << EOF > input bla bla @@ -119,16 +119,16 @@ Bug: #123 EOF ${hook} input || fail "failed hook execution" - result=$(git interpret-trailers --parse input | head -1 | grep ^Change-Id) + result=$(tail -1 input | grep ^Change-Id) if [[ -z "${result}" ]] ; then echo "after: " cat input - fail "did not find Change-Id at start" + fail "did not find Change-Id at end" fi } -function test_dash_at_start { +function test_dash_at_end { if [[ ! -x /bin/dash ]] ; then echo "/bin/dash not installed; skipping dash test." return @@ -142,12 +142,12 @@ EOF /bin/dash ${hook} input || fail "failed hook execution" - result=$(git interpret-trailers --parse input | head -1 | grep ^Change-Id) + result=$(tail -1 input | grep ^Change-Id) if [[ -z "${result}" ]] ; then echo "after: " cat input - fail "did not find Change-Id at start" + fail "did not find Change-Id at end" fi } diff --git a/resources/com/google/gerrit/server/tools/root/hooks/commit-msg b/resources/com/google/gerrit/server/tools/root/hooks/commit-msg index 2b1a2fc1c4..290123258b 100755 --- a/resources/com/google/gerrit/server/tools/root/hooks/commit-msg +++ b/resources/com/google/gerrit/server/tools/root/hooks/commit-msg @@ -50,7 +50,7 @@ fi # Avoid the --in-place option which only appeared in Git 2.8 # Avoid the --if-exists option which only appeared in Git 2.15 -if ! git -c trailer.ifexists=doNothing interpret-trailers --where start \ +if ! git -c trailer.ifexists=doNothing interpret-trailers \ --trailer "Change-Id: I${random}" < "$1" > "${dest}" ; then echo "cannot insert change-id line in $1" exit 1