From d18cc13199ecb8ad833f759006fdf68b7703878c Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Thu, 7 Mar 2024 09:28:37 +0100 Subject: Complain if qt_attribution.json is modified without changelog entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the qt_attribution.json file is modified without a corresponding [ChangeLog][Third-Party Code] entry in the commit message, or vise versa, give a -1 sanity vote. Task-number: QTQAINFRA-6097 Change-Id: I959e0a0678faaae2578911c1d4ee3dd5d3ca61d8 Reviewed-by: Kai Köhne --- git-hooks/sanitize-commit | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'git-hooks') diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit index 0d291a6..b01300b 100755 --- a/git-hooks/sanitize-commit +++ b/git-hooks/sanitize-commit @@ -420,6 +420,7 @@ my ($coverity, $cid) = (0, 0); my $msgline = 0; my %picktos = (); my $prevline = ""; +my $changelog3rdparty = 0; open MSG, "git cat-file -p ".$sha1." |" or die "cannot run git: $!"; while () { last if ($_ eq "\n"); @@ -547,6 +548,8 @@ while () { $inchangelog = 1; if (!/^\[ChangeLog\]/ && !defined($cfg{changelog})) { complain_ln("Bad form of [ChangeLog] tag", "changelog"); + } elsif (/\[ChangeLog\]\[Third-Party Code\]/) { + $changelog3rdparty = 1; } } elsif (/^\[[A-Z][- \w]+\]/) { complain_ln("Likely change-log entry without [ChangeLog] tag", "", -1); @@ -813,6 +816,7 @@ my $eof_check; my $ctlkw_check; my $apple_check; my $notobjc_check; +my $attribution_changed; open DIFF, "git diff-tree --minimal --no-commit-id --diff-filter=ACMR --ignore-submodules " . "--src-prefix=\@old\@/ --dst-prefix=\@new\@/ --full-index -r -U100000 --cc -C -l1000 " . "--root ".$sha1." |" or die "cannot run git: $!"; @@ -969,6 +973,12 @@ while () { } $file = $1; #print "*** got file ".$file.".\n"; + if ($file =~ /qt_attribution\.json$/) { + $attribution_changed = 1; + if (!$changelog3rdparty) { + complain("qt_attribution.json changed without [ChangeLog][Third-Party Code] in the commit message", "changelog"); + } + } $clike = ($file =~ /\.(c|cc|cpp|c\+\+|cxx|qdoc|m|mm|h|hpp|hxx|cs|java|js|qs|qml|g|y|ypp|pl|glsl)$/i); $qmake = ($file =~ /\.pr[filo]$/i); $is_bin = ($file =~ /\.(ps|pdf)$/); @@ -1082,6 +1092,11 @@ while () { close DIFF; printerr; flushFile(); + +if ($changelog3rdparty && !$attribution_changed) { + complain("[ChangeLog][Third-Party Code] entry without change to qt_attribution.json", "changelog"); +} + if ($mixws_check) { flushChunk() if ($chunk); if ($nonws and $ws) { -- cgit v1.2.3