From 879d1ba4d4dd1eba5bb38c1f8653ccb89d854a2a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Date: Tue, 18 Mar 2014 21:07:12 +0100 Subject: [PATCH] complain about gerrit ids in commit messages outside Change-Id footer people use them to refer to related commits. they should use stable sha1s of merged commits instead. Change-Id: Ic58aa875aa978dc76948521266741258fd8c94aa Reviewed-by: Sergio Ahumada <sahumada@blackberry.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- git-hooks/sanitize-commit | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index 06183c9..c31d8f2 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -95,6 +95,7 @@ my $lineno = 0; my $iswip = defined($cfg{wip}); my $badrev = 0; my $badsign = 0; +my $badid = defined($cfg{changeid}); my $badlog = defined($cfg{log}); my $spell_check = !defined($cfg{spell}); my $parents = 0; @@ -213,6 +214,10 @@ while (<MSG>) { if (!$badsign && /^Signed-off-by:/i) { $badsign = 1; } + if (!$badid && /\bI[0-9a-f]{40}\b/ && !/^Change-Id: /) { + $badid = 1; + &complain("Gerrit change id outside Change-Id footer", "changeid"); + } my $ftr = 0; if (/^\(cherry[- ]picked /) { $cherry = 1 if (!/\)/); -- GitLab