Merge ~vicamo/+git/hwe-tools:for-upstream/support-upstream-statements into ~vicamo/+git/hwe-tools:master

Proposed by You-Sheng Yang
Status: Merged
Merged at revision: 56af6c40e9f8101f026e5d1d4c3475ecc9a8eacf
Proposed branch: ~vicamo/+git/hwe-tools:for-upstream/support-upstream-statements
Merge into: ~vicamo/+git/hwe-tools:master
Diff against target: 299 lines (+118/-36)
4 files modified
find-upstream-fixes (+77/-14)
get-oem-delta.sh (+20/-12)
hwe-bug-checker.py (+1/-1)
hwe-bug-monitor.py (+20/-9)
Reviewer Review Type Date Requested Status
Canonical Hardware Enablement Pending
Review via email: mp+405173@code.launchpad.net

Description of the change

* remove debug prints
* detect `[ Upstream commit ... ]` and `commit ... upstream.`.

TODO: figure out why there are sometimes:

  fatal: bad object ...
  fatal: Not a valid commit name ...

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/find-upstream-fixes b/find-upstream-fixes
2index 358df33..f1d6874 100755
3--- a/find-upstream-fixes
4+++ b/find-upstream-fixes
5@@ -1,10 +1,40 @@
6 #!/bin/bash
7
8+BOT=0
9+BOT_HEADER=""
10+BOT_COMMITS=""
11+QUIET=0
12+
13+function println() {
14+ if [ ${QUIET} -ne 1 ] || [ ! -z $2 ]; then
15+ if [ ${BOT} -ne 1 ]; then
16+ echo "$1"
17+ fi
18+ fi
19+}
20+
21 if [ $# -lt 2 ]; then
22- echo "Usage: ${BASH_SOURCE[0]} <ref-range> <find1>[ <find2>...]" >&2
23+ echo "Usage: ${BASH_SOURCE[0]} [-b -q] <ref-range> <find1>[ <find2>...]" >&2
24 exit 1
25 fi
26
27+OPTIND=1
28+while getopts ":bqh?" opt; do
29+ case ${opt} in
30+ b)
31+ QUIET=1
32+ BOT=1
33+ ;;
34+ q)
35+ QUIET=1
36+ ;;
37+ *)
38+ ;;
39+ esac
40+done
41+
42+shift $((OPTIND-1))
43+[ "${1:-}" = "--" ] && shift
44 COMMIT_RANGE=$1
45 shift;
46 TARGET_TREES=("$@")
47@@ -14,22 +44,31 @@ declare -A cherry_picked;
48
49 header_printed=
50 for commit in $(git log --reverse --pretty=format:%h "${COMMIT_RANGE}"); do
51- corb=( $(git log -1 --pretty=format:%b "${commit}" | \
52+ msg="$(git log -1 --pretty=format:%b "${commit}")"
53+ todo=( $(echo "${msg}" | \
54 grep -E '^\((cherry picked|backported) from commit ' | \
55 sed -E 's,^\((cherry picked|backported) from commit ([a-f0-9]+).*,\2,') )
56- if [ ${#corb} -ne 0 ]; then
57- cherry_picked["${commit}"]="${corb[*]}"
58+ todo+=( $(echo "${msg}" | \
59+ grep -E '^\[ Upstream commit [a-f0-9]+ \]$' | \
60+ sed -E 's,^\[ Upstream commit ([a-f0-9]+) \]$,\1,') )
61+ todo+=( $(echo "${msg}" | \
62+ grep -E '^commit [a-f0-9]+ upstream.$' | \
63+ sed -E 's,^commit ([a-f0-9]+) upstream.$,\1,') )
64+ if [ ${#todo} -ne 0 ]; then
65+ cherry_picked["${commit}"]="${todo[*]}"
66 continue
67 fi
68
69 if [ -z "${header_printed}" ]; then
70- echo "* No cherry-pick/backport statement found:"
71+ println "* No cherry-pick/backport/upstream statement found:"
72 header_printed=yes
73 fi
74
75- echo " * commit ${commit} (\"$(git log -1 --pretty=format:%s "${commit}")\")"
76- git log -1 --pretty=format:%b "${commit}"
77- echo
78+ println " * commit ${commit} (\"$(git log -1 --pretty=format:%s "${commit}")\")"
79+ if [ ${QUIET} -ne 1 ]; then
80+ git log -1 --pretty=format:%b "${commit}"
81+ fi
82+ println ""
83 done
84
85 for checking in "${!cherry_picked[@]}"; do
86@@ -38,31 +77,55 @@ for checking in "${!cherry_picked[@]}"; do
87
88 for needle in ${origins}; do
89 needle_printed=
90- needle_short=$(git log -1 --pretty=format:%h "${needle}")
91+ if [ ${QUIET} -eq 1 ]; then
92+ needle_short=$(git log -1 --pretty=format:%h "${needle}" 2> /dev/null)
93+ else
94+ needle_short=$(git log -1 --pretty=format:%h "${needle}")
95+ fi
96
97+ BOT_HEADER=""
98 for haystack in "${TARGET_TREES[@]}"; do
99- git merge-base --is-ancestor "${needle}" "${haystack}" || continue
100+ if [ ${QUIET} -eq 1 ]; then
101+ git merge-base --is-ancestor "${needle}" "${haystack}" 2> /dev/null || continue
102+ else
103+ git merge-base --is-ancestor "${needle}" "${haystack}" || continue
104+ fi
105
106 found=( $(git log -P --grep="^\s*Fixes:.*\s+${needle_short}" --pretty="format:%h" "${needle_short}..${haystack}") )
107 [ ${#found} -ne 0 ] || continue
108
109 if [ -z "${header_printed}" ]; then
110- echo "###### Checking commit ${checking} (\"$(git log -1 --pretty=format:%s "${checking}")\") ######"
111+ println "###### Checking commit ${checking} (\"$(git log -1 --pretty=format:%s "${checking}")\") ######" 1
112 header_printed=yes
113+ if [ ${BOT} -eq 1 ]; then
114+ branch=`git branch --show-current`
115+ BOT_HEADER="###### Branch ${branch} commit ${checking} (\"$(git log -1 --pretty=format:%s "${checking}")\") ######"
116+ BOT_COMMITS=""
117+ fi
118 fi
119 if [ -z "${needle_printed}" ]; then
120- echo " * Checking for origin ${needle_short} ..."
121+ println " * Checking for origin ${needle_short} ..." 1
122 needle_printed=yes
123 fi
124
125- echo " fixes found in ${haystack}: ${found[*]}"
126+ println " fixes found in ${haystack}: ${found[*]}" 1
127+ if [ ${BOT} -eq 1 ]; then
128+ BOT_COMMITS+=" fixes found in ${haystack}: ${found[*]}\n"
129+ break
130+ fi
131 for fix in "${found[@]}"; do
132 case " ${cherry_picked[@]} " in
133 *" ${fix}"*) format="(applied) %h %s" ;;
134 *) format="(missing) %h %s" ;;
135 esac
136- git log -1 --pretty="format: ${format}" "${fix}"
137+ if [ ${QUIET} -ne 1 ]; then
138+ git log -1 --pretty="format: ${format}" "${fix}"
139+ fi
140 done
141 done
142+ if [ ${BOT} -eq 1 ] && [ ! -z "${BOT_HEADER}" ] ; then
143+ echo -e "${BOT_HEADER}"
144+ echo -e "${BOT_COMMITS}"
145+ fi
146 done
147 done
148diff --git a/get-oem-delta.sh b/get-oem-delta.sh
149index 89f617c..540e7c3 100755
150--- a/get-oem-delta.sh
151+++ b/get-oem-delta.sh
152@@ -11,7 +11,7 @@
153 # Where your linux-oem tree lives
154 OEM_KERNEL_TREE=
155 OEM_KERNEL_BRANCH="oem"
156-GIT_PULL=0
157+GIT_PULL=1
158 WIDE_MODE=0
159
160 bye() { cd "$pwd"; exit $1; }
161@@ -24,9 +24,9 @@ usage()
162 echo -e " -b \e[3m<oem_kernel_branch>\e[0m\tBranch name to checkout in OEM kernel git repo, default is 'oem'";
163 echo -e " -t \e[3m<target_git_repo>\e[0m\t\tGit repo to check whether commits have landed";
164 echo -e " -B \e[3m<target_repo_branch>\e[0m\tBranch to switch to in the target kernel git repo (optional)";
165- echo -e " -p \t\t\t\tRuns git pull --rebase in the source and target git repos, default is not to git pull";
166 echo -e " -w \t\t\t\tWide mode, suitable for file output, not suitable for screen display";
167 echo -e " -T \e[3m<hash>\e[0m\t\t\tIf \e[3m<hash>\e[0m is provided then will only test this hash";
168+ echo -e " -P \t\t\t\tDO NOT run 'git pull --rebase' in the source and target git repos";
169 echo -e " -d \t\t\t\tDebug mode";
170 echo -e " -h \t\t\t\tPrint this help";
171 echo
172@@ -39,7 +39,7 @@ escape()
173 echo $1 | sed -E 's/([][*])/\\\1/g'
174 }
175
176-while getopts ":hps:b:t:B:wdT:" opt; do
177+while getopts ":hPs:b:t:B:wdT:" opt; do
178 case ${opt} in
179 s)
180 if [ -d $OPTARG ]; then
181@@ -61,8 +61,8 @@ while getopts ":hps:b:t:B:wdT:" opt; do
182 B)
183 TARGET_GIT_BRANCH=$OPTARG
184 ;;
185- p)
186- GIT_PULL=1
187+ P)
188+ GIT_PULL=0
189 ;;
190 w)
191 WIDE_MODE=1
192@@ -87,27 +87,35 @@ shift $((OPTIND -1))
193
194 pwd="$PWD"
195
196-cd "$OEM_KERNEL_TREE"
197+cd "$target_repo"
198 (
199-git remote | grep -q mainline || (print_err "mainline remote missing in OEM kernel tree"; bye 1)
200-git checkout $OEM_KERNEL_BRANCH
201+[ -n $TARGET_GIT_BRANCH ] && git checkout $TARGET_GIT_BRANCH
202 [ $GIT_PULL = 1 ] && git pull --rebase
203 ) 1>&2
204+target_origin=`git remote get-url origin`
205+target_head_hash=`git rev-parse --short HEAD`
206+target_branch=`git branch --show-current`
207
208+cd "$OEM_KERNEL_TREE"
209 (
210-cd "$target_repo"
211-[ -n $TARGET_GIT_BRANCH ] && git checkout $TARGET_GIT_BRANCH
212+git remote | grep -q mainline || (print_err "mainline remote missing in OEM kernel tree"; bye 1)
213+git checkout $OEM_KERNEL_BRANCH
214+git fetch mainline
215 [ $GIT_PULL = 1 ] && git pull --rebase
216 ) 1>&2
217-
218+source_origin=`git remote get-url origin`
219+source_head_hash=`git rev-parse --short HEAD`
220+source_branch=`git branch --show-current`
221
222 FIRST_AND_LAST_HASH=( `git log --oneline -E --grep "UBUNTU: Ubuntu-[1-9]+" | sort -rV -k3 | awk 'NR==1 { print $1 }; END { print $1 }'` )
223 LATEST_UBUNTU_HASH=${FIRST_AND_LAST_HASH[0]}
224 EARLIEST_UBUNTU_HASH_DATE=`git log -1 --format=%aI ${FIRST_AND_LAST_HASH[1]}`
225
226 printf "Report generated at "; date
227+printf "Source: $source_origin $source_head_hash ($source_branch)\n"
228+printf "Target: $target_origin $target_head_hash ($target_branch)\n"
229 printf "T=Type: C=Cherry-pick, B=Backport, S=SAUCE patch, R=Revert, F=conFig\n"
230-printf "L=Landed in %s?\n" "${target_repo}"
231+printf "L=Landed?\n"
232 printf " + Y=Landed, N=Not landed, M=Log messages differ but w/ identical patch contents\n"
233 printf " + x%%=Commit with same log message found but patch contents differ\n"
234 perl -e 'print "-" x 180; print "\n"'
235diff --git a/hwe-bug-checker.py b/hwe-bug-checker.py
236index 89fdbc5..ec8f51a 100755
237--- a/hwe-bug-checker.py
238+++ b/hwe-bug-checker.py
239@@ -12,7 +12,7 @@ from launchpadlib.uris import lookup_service_root
240
241 APP_NAME = 'hwe-bug-checker'
242 SERVICE_ROOT = 'production'
243-HWE_OEM_PROJECTS = ['somerville/hwe-somerville', 'sutton/hwe-sutton', 'stella/hwe-stella', 'busan/hwe-busan', 'nashville/hwe-nashville', 'amaro/hwe-amaro', 'timbuktu/hwe-timbuktu', 'denver/hwe-denver']
244+HWE_OEM_PROJECTS = ['somerville/hwe-somerville', 'sutton/hwe-sutton', 'stella/hwe-stella', 'busan/hwe-busan', 'nashville/hwe-nashville', 'amaro/hwe-amaro', 'timbuktu/hwe-timbuktu', 'denver/hwe-denver', 'anle/hwe-anle', 'pygmy-possum/hwe-pygmy-possum']
245
246 logger = getLogger(APP_NAME)
247
248diff --git a/hwe-bug-monitor.py b/hwe-bug-monitor.py
249index 2aff1cf..519776b 100755
250--- a/hwe-bug-monitor.py
251+++ b/hwe-bug-monitor.py
252@@ -1,27 +1,38 @@
253 #!/usr/bin/python3
254
255+import re
256+
257 from os import path
258 from subprocess import getoutput, getstatusoutput
259
260 HWE_BUG_CHECKER = '~/hwe-tools/hwe-bug-checker.py'
261-OEM_KERNELS = ['bionic git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/bionic oem-next',
262- 'focal git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/focal oem-5.6-next',
263- 'focal git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/focal oem-5.10-next']
264+OEM_KERNELS = ['focal git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/focal oem-5.14-next Ubuntu-oem-5.14',
265+ 'jammy git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/jammy oem-5.17-next Ubuntu-oem-5.17']
266
267 for kernel in OEM_KERNELS:
268 local = kernel.split(' ')[0]
269 repo = kernel.split(' ')[1]
270 branch = kernel.split(' ')[2]
271+ tag_prefix = kernel.split(' ')[3]
272 print("%s %s %s" % (local, repo, branch))
273 if not path.exists(local):
274 getoutput("git clone --depth 1 --single-branch --branch %s %s %s" % (branch, repo, local))
275- else:
276- status, result = getstatusoutput("cd %s; git rev-parse --verify %s" % (local, branch))
277- if status != 0:
278- print("hwe-bug-checker: adding new branch - %s" % branch)
279- getoutput("cd %s; git remote set-branches --add origin %s" % (local, branch))
280+ status, result = getstatusoutput("cd %s; git rev-parse --verify %s" % (local, branch))
281+ if status != 0:
282+ print("hwe-bug-checker: adding new branch - %s" % branch)
283+ getoutput("cd %s; git remote set-branches --add origin %s" % (local, branch))
284+ getoutput("cd %s; git remote set-branches origin %s" % (local, branch))
285 result = getoutput("(cd %s; git fetch origin)" % local)
286- if 'new tag' in result:
287+ for line in result.splitlines():
288+ tag_pattern = re.compile(r" \* \[new tag\] +(.*) -> (.*)")
289+ tag = tag_pattern.match(line)
290+ if tag != None:
291+ if tag_prefix not in tag[1]:
292+ getoutput("cd %s; git tag -d %s" % (local, tag[1]))
293+ continue
294+ else:
295+ continue
296+
297 getoutput("(cd %s; git checkout -B %s origin/%s)" % (local, branch, branch))
298 result = getoutput("(cd %s; %s)" % (local, HWE_BUG_CHECKER))
299 print("hwe-bug-checker: %s" % result)

Subscribers

People subscribed via source and target branches

to all changes: