Debian Codegraph @

tools/check-cherry-picks.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 #
3 # A tool to check the cherry-pick hashes from the current git commit message
4 # to verify that they're all on either master, stable/ or unmaintained/ branches
5 #
6
7 commit_hash=""
8
9 # Check if the patch is a merge patch by counting the number of parents.
10 # If the patch has 2 parents, then the 2nd parent is the patch we want
11 # to validate.
12 parent_number=$(gitscip-shell system . . git. show --format='%P' --quiet | awkscip-shell system . . awk. '{print NF}')
13 if [scip-shell system . . `[`. $parent_number -eq 2 ]; then
14 commit_hash=$(gitscip-shell system . . git. show --format='%P' --quiet | awkscip-shell system . . awk. '{print $NF}')
15 fi
16
17 if gitscip-shell system . . git. show --format='%aE' --quiet ${commit_hash} | grepscip-shell system . . grep. -qi '[email protected]'; then
18 echoscip-shell system . . echo. 'Bot generated change; ignoring'
19 exit 0
20 fi
21
22 hashes=$(gitscip-shell system . . git. show --format='%b' --quiet ${commit_hash} | sedscip-shell system . . sed. -nr 's/^.cherry picked from commit (.*).$/\1/p')
23 checked=0
24 branches+=""
25 for hash in $hashes; do
26 branch=$(gitscip-shell system . . git. branch -a --contains "$hash" 2>/dev/nullscip-shell filesystem . . `/dev/null`.| grepscip-shell system . . grep. -oE '(master|stable/[a-z0-9.]+|unmaintained/[a-z0-9.]+)')
27 if [scip-shell system . . `[`. $? -ne 0 ]; then
28 branch=$(gitscip-shell system . . git. tag --contains "$hash" 2>/dev/nullscip-shell filesystem . . `/dev/null`.| grepscip-shell system . . grep. -oE '([0-9.]+-eol)')
29 if [scip-shell system . . `[`. $? -ne 0 ]; then
30 echoscip-shell system . . echo. "Cherry pick hash $hash not on any master, stable, unmaintained or EOL'd branches"
31 exit 1
32 fi
33 fi
34 branches+=" $branch"
35 checked=$(($checked + 1))
36 done
37
38 if [scip-shell system . . `[`. $checked -eq 0 ]; then
39 if ! grepscip-shell system . . grep. -qE '^defaultbranch=(stable|unmaintained)/' .gitreview; then
40 echoscip-shell system . . echo. "Checked $checked cherry-pick hashes: OK"
41 exit 0
42 else
43 if ! gitscip-shell system . . git. show --format='%B' --quiet ${commit_hash} | grepscip-shell system . . grep. -qi 'stable.*only'; then
44 echoscip-shell system . . echo. 'Stable branch requires either cherry-pick -x headers or [stable-only] tag!'
45 exit 1
46 fi
47 fi
48 else
49 echoscip-shell system . . echo. Checked $checked cherry-pick hashes on branches: $(echoscip-shell system . . echo. $branches | trscip-shell system . . tr. ' ' '\n' | sortscip-shell system . . sort. | uniqscip-shell system . . uniq.)
50 fi