summaryrefslogtreecommitdiffstats
path: root/git-hooks
diff options
context:
space:
mode:
authorDaniel Smith <daniel.smith@qt.io>2023-07-10 12:18:43 +0200
committerDaniel Smith <Daniel.Smith@qt.io>2023-09-11 13:09:19 +0000
commit925e5722f5c9647eca0744a905fe998cadd1a661 (patch)
treea17a1a78f2c0a94153432f4a240499604421a5bc /git-hooks
parent5eb547fab9e7807d1533023dca5ba6ee2583b74f (diff)
Remove warning about leftover Pick-to footers in cherry-picks
The cherry-pick bot will now "waterfall" changes down from newest to oldest, so Pick-to footers are expected to remain in cherry-picks until all targets are exhausted. Ideally, we'd ensure that no excess entries remain, but that would require examining the named branches, which would be complex and would require ensuring that the refs are current, which both seem unreasonable. Therefore, we simply suppress the check in cherry-picks. Change-Id: I20a77603779654d113e80121b50491239c048e36 Reviewed-by: Daniel Smith <Daniel.Smith@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'git-hooks')
-rwxr-xr-xgit-hooks/sanitize-commit87
1 files changed, 40 insertions, 47 deletions
diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit
index b8faf1a..d9b065c 100755
--- a/git-hooks/sanitize-commit
+++ b/git-hooks/sanitize-commit
@@ -599,58 +599,51 @@ if ($badsign) {
if ($coverity && !$cid) {
do_complain($coverity, "Mention of Coverity without Coverity-Id footer is probably incorrect", "");
}
-if ($with_pickbot) {
- if ($havecherry) {
- if (%picktos) {
- complain("Leftover Pick-to footer in commit message of cherry-picked change",
- "cherry", 1);
- }
+if ($with_pickbot && !$havecherry) {
+ my $onDev;
+ my $masterName = $foundDev ? "dev" : "master";
+ if (defined($target)) {
+ $onDev = ($target eq $masterName) || ($target =~ m,^wip/,);
} else {
- my $onDev;
- my $masterName = $foundDev ? "dev" : "master";
- if (defined($target)) {
- $onDev = ($target eq $masterName) || ($target =~ m,^wip/,);
- } else {
- my $masterRev = $allHeads{$masterName};
- chomp(my $sha1Base = `git merge-base $sha1 $masterRev`);
- # Catch both ancestor and descendant cases.
- $onDev = ($sha1Base eq $sha1 || $sha1Base eq $masterRev);
- }
- if (!$onDev) {
- if (%picktos) {
- if (exists($picktos{$masterName})) {
- complain("Picking downward from $masterName is preferred", "", -1);
- } else {
- complain("Omission of $masterName from Pick-to footer might be incorrect",
- "", -1);
- }
- if ($target =~ /(\d+\.\d+)\.\d+$/) {
- # Verify that the upstream stable branch is in the pick-to if the current
- # target is a release branch.
- if (!exists($picktos{$1})) {
- complain("Omission of $1 from the Pick-to footer is probably incorrect",
- "cherry")
- }
- }
+ my $masterRev = $allHeads{$masterName};
+ chomp(my $sha1Base = `git merge-base $sha1 $masterRev`);
+ # Catch both ancestor and descendant cases.
+ $onDev = ($sha1Base eq $sha1 || $sha1Base eq $masterRev);
+ }
+ if (!$onDev) {
+ if (%picktos) {
+ if (exists($picktos{$masterName})) {
+ complain("Picking downward from $masterName is preferred", "", -1);
} else {
- complain("Omission of Pick-to footer is probably incorrect", "cherry");
+ complain("Omission of $masterName from Pick-to footer might be incorrect",
+ "", -1);
}
- } elsif (%picktos) {
- my %majors;
- # Populate a hash of majors with arrays of stable branches
- foreach (keys %allHeads) {
- if (/^(\d+)\.(\d+)$/) {
- push @{$majors{$1}}, $2;
+ if ($target =~ /(\d+\.\d+)\.\d+$/) {
+ # Verify that the upstream stable branch is in the pick-to if the current
+ # target is a release branch.
+ if (!exists($picktos{$1})) {
+ complain("Omission of $1 from the Pick-to footer is probably incorrect",
+ "cherry")
}
}
- foreach (sort keys %majors) {
- if (@{$majors{$_}} >= 2) {
- my @major = sort { $a <=> $b } @{$majors{$_}};
- my ($latest, $previous) = ("$_.$major[-1]", "$_.$major[-2]");
- if (exists($picktos{$previous}) && !exists($picktos{$latest})) {
- complain("Omission of $latest from cherry-pick targets".
- " is probably incorrect", "cherry");
- }
+ } else {
+ complain("Omission of Pick-to footer is probably incorrect", "cherry");
+ }
+ } elsif (%picktos) {
+ my %majors;
+ # Populate a hash of majors with arrays of stable branches
+ foreach (keys %allHeads) {
+ if (/^(\d+)\.(\d+)$/) {
+ push @{$majors{$1}}, $2;
+ }
+ }
+ foreach (sort keys %majors) {
+ if (@{$majors{$_}} >= 2) {
+ my @major = sort { $a <=> $b } @{$majors{$_}};
+ my ($latest, $previous) = ("$_.$major[-1]", "$_.$major[-2]");
+ if (exists($picktos{$previous}) && !exists($picktos{$latest})) {
+ complain("Omission of $latest from cherry-pick targets".
+ " is probably incorrect", "cherry");
}
}
}