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
diff --git a/find-upstream-fixes b/find-upstream-fixes
index 358df33..f1d6874 100755
--- a/find-upstream-fixes
+++ b/find-upstream-fixes
@@ -1,10 +1,40 @@
1#!/bin/bash1#!/bin/bash
22
3BOT=0
4BOT_HEADER=""
5BOT_COMMITS=""
6QUIET=0
7
8function println() {
9 if [ ${QUIET} -ne 1 ] || [ ! -z $2 ]; then
10 if [ ${BOT} -ne 1 ]; then
11 echo "$1"
12 fi
13 fi
14}
15
3if [ $# -lt 2 ]; then16if [ $# -lt 2 ]; then
4 echo "Usage: ${BASH_SOURCE[0]} <ref-range> <find1>[ <find2>...]" >&217 echo "Usage: ${BASH_SOURCE[0]} [-b -q] <ref-range> <find1>[ <find2>...]" >&2
5 exit 118 exit 1
6fi19fi
720
21OPTIND=1
22while getopts ":bqh?" opt; do
23 case ${opt} in
24 b)
25 QUIET=1
26 BOT=1
27 ;;
28 q)
29 QUIET=1
30 ;;
31 *)
32 ;;
33 esac
34done
35
36shift $((OPTIND-1))
37[ "${1:-}" = "--" ] && shift
8COMMIT_RANGE=$138COMMIT_RANGE=$1
9shift;39shift;
10TARGET_TREES=("$@")40TARGET_TREES=("$@")
@@ -14,22 +44,31 @@ declare -A cherry_picked;
1444
15header_printed=45header_printed=
16for commit in $(git log --reverse --pretty=format:%h "${COMMIT_RANGE}"); do46for commit in $(git log --reverse --pretty=format:%h "${COMMIT_RANGE}"); do
17 corb=( $(git log -1 --pretty=format:%b "${commit}" | \47 msg="$(git log -1 --pretty=format:%b "${commit}")"
48 todo=( $(echo "${msg}" | \
18 grep -E '^\((cherry picked|backported) from commit ' | \49 grep -E '^\((cherry picked|backported) from commit ' | \
19 sed -E 's,^\((cherry picked|backported) from commit ([a-f0-9]+).*,\2,') )50 sed -E 's,^\((cherry picked|backported) from commit ([a-f0-9]+).*,\2,') )
20 if [ ${#corb} -ne 0 ]; then51 todo+=( $(echo "${msg}" | \
21 cherry_picked["${commit}"]="${corb[*]}"52 grep -E '^\[ Upstream commit [a-f0-9]+ \]$' | \
53 sed -E 's,^\[ Upstream commit ([a-f0-9]+) \]$,\1,') )
54 todo+=( $(echo "${msg}" | \
55 grep -E '^commit [a-f0-9]+ upstream.$' | \
56 sed -E 's,^commit ([a-f0-9]+) upstream.$,\1,') )
57 if [ ${#todo} -ne 0 ]; then
58 cherry_picked["${commit}"]="${todo[*]}"
22 continue59 continue
23 fi60 fi
2461
25 if [ -z "${header_printed}" ]; then62 if [ -z "${header_printed}" ]; then
26 echo "* No cherry-pick/backport statement found:"63 println "* No cherry-pick/backport/upstream statement found:"
27 header_printed=yes64 header_printed=yes
28 fi65 fi
2966
30 echo " * commit ${commit} (\"$(git log -1 --pretty=format:%s "${commit}")\")"67 println " * commit ${commit} (\"$(git log -1 --pretty=format:%s "${commit}")\")"
31 git log -1 --pretty=format:%b "${commit}"68 if [ ${QUIET} -ne 1 ]; then
32 echo69 git log -1 --pretty=format:%b "${commit}"
70 fi
71 println ""
33done72done
3473
35for checking in "${!cherry_picked[@]}"; do74for checking in "${!cherry_picked[@]}"; do
@@ -38,31 +77,55 @@ for checking in "${!cherry_picked[@]}"; do
3877
39 for needle in ${origins}; do78 for needle in ${origins}; do
40 needle_printed=79 needle_printed=
41 needle_short=$(git log -1 --pretty=format:%h "${needle}")80 if [ ${QUIET} -eq 1 ]; then
81 needle_short=$(git log -1 --pretty=format:%h "${needle}" 2> /dev/null)
82 else
83 needle_short=$(git log -1 --pretty=format:%h "${needle}")
84 fi
4285
86 BOT_HEADER=""
43 for haystack in "${TARGET_TREES[@]}"; do87 for haystack in "${TARGET_TREES[@]}"; do
44 git merge-base --is-ancestor "${needle}" "${haystack}" || continue88 if [ ${QUIET} -eq 1 ]; then
89 git merge-base --is-ancestor "${needle}" "${haystack}" 2> /dev/null || continue
90 else
91 git merge-base --is-ancestor "${needle}" "${haystack}" || continue
92 fi
4593
46 found=( $(git log -P --grep="^\s*Fixes:.*\s+${needle_short}" --pretty="format:%h" "${needle_short}..${haystack}") )94 found=( $(git log -P --grep="^\s*Fixes:.*\s+${needle_short}" --pretty="format:%h" "${needle_short}..${haystack}") )
47 [ ${#found} -ne 0 ] || continue95 [ ${#found} -ne 0 ] || continue
4896
49 if [ -z "${header_printed}" ]; then97 if [ -z "${header_printed}" ]; then
50 echo "###### Checking commit ${checking} (\"$(git log -1 --pretty=format:%s "${checking}")\") ######"98 println "###### Checking commit ${checking} (\"$(git log -1 --pretty=format:%s "${checking}")\") ######" 1
51 header_printed=yes99 header_printed=yes
100 if [ ${BOT} -eq 1 ]; then
101 branch=`git branch --show-current`
102 BOT_HEADER="###### Branch ${branch} commit ${checking} (\"$(git log -1 --pretty=format:%s "${checking}")\") ######"
103 BOT_COMMITS=""
104 fi
52 fi105 fi
53 if [ -z "${needle_printed}" ]; then106 if [ -z "${needle_printed}" ]; then
54 echo " * Checking for origin ${needle_short} ..."107 println " * Checking for origin ${needle_short} ..." 1
55 needle_printed=yes108 needle_printed=yes
56 fi109 fi
57110
58 echo " fixes found in ${haystack}: ${found[*]}"111 println " fixes found in ${haystack}: ${found[*]}" 1
112 if [ ${BOT} -eq 1 ]; then
113 BOT_COMMITS+=" fixes found in ${haystack}: ${found[*]}\n"
114 break
115 fi
59 for fix in "${found[@]}"; do116 for fix in "${found[@]}"; do
60 case " ${cherry_picked[@]} " in117 case " ${cherry_picked[@]} " in
61 *" ${fix}"*) format="(applied) %h %s" ;;118 *" ${fix}"*) format="(applied) %h %s" ;;
62 *) format="(missing) %h %s" ;;119 *) format="(missing) %h %s" ;;
63 esac120 esac
64 git log -1 --pretty="format: ${format}" "${fix}"121 if [ ${QUIET} -ne 1 ]; then
122 git log -1 --pretty="format: ${format}" "${fix}"
123 fi
65 done124 done
66 done125 done
126 if [ ${BOT} -eq 1 ] && [ ! -z "${BOT_HEADER}" ] ; then
127 echo -e "${BOT_HEADER}"
128 echo -e "${BOT_COMMITS}"
129 fi
67 done130 done
68done131done
diff --git a/get-oem-delta.sh b/get-oem-delta.sh
index 89f617c..540e7c3 100755
--- a/get-oem-delta.sh
+++ b/get-oem-delta.sh
@@ -11,7 +11,7 @@
11# Where your linux-oem tree lives11# Where your linux-oem tree lives
12OEM_KERNEL_TREE=12OEM_KERNEL_TREE=
13OEM_KERNEL_BRANCH="oem"13OEM_KERNEL_BRANCH="oem"
14GIT_PULL=014GIT_PULL=1
15WIDE_MODE=015WIDE_MODE=0
1616
17bye() { cd "$pwd"; exit $1; }17bye() { cd "$pwd"; exit $1; }
@@ -24,9 +24,9 @@ usage()
24 echo -e " -b \e[3m<oem_kernel_branch>\e[0m\tBranch name to checkout in OEM kernel git repo, default is 'oem'";24 echo -e " -b \e[3m<oem_kernel_branch>\e[0m\tBranch name to checkout in OEM kernel git repo, default is 'oem'";
25 echo -e " -t \e[3m<target_git_repo>\e[0m\t\tGit repo to check whether commits have landed";25 echo -e " -t \e[3m<target_git_repo>\e[0m\t\tGit repo to check whether commits have landed";
26 echo -e " -B \e[3m<target_repo_branch>\e[0m\tBranch to switch to in the target kernel git repo (optional)";26 echo -e " -B \e[3m<target_repo_branch>\e[0m\tBranch to switch to in the target kernel git repo (optional)";
27 echo -e " -p \t\t\t\tRuns git pull --rebase in the source and target git repos, default is not to git pull";
28 echo -e " -w \t\t\t\tWide mode, suitable for file output, not suitable for screen display";27 echo -e " -w \t\t\t\tWide mode, suitable for file output, not suitable for screen display";
29 echo -e " -T \e[3m<hash>\e[0m\t\t\tIf \e[3m<hash>\e[0m is provided then will only test this hash";28 echo -e " -T \e[3m<hash>\e[0m\t\t\tIf \e[3m<hash>\e[0m is provided then will only test this hash";
29 echo -e " -P \t\t\t\tDO NOT run 'git pull --rebase' in the source and target git repos";
30 echo -e " -d \t\t\t\tDebug mode";30 echo -e " -d \t\t\t\tDebug mode";
31 echo -e " -h \t\t\t\tPrint this help";31 echo -e " -h \t\t\t\tPrint this help";
32 echo32 echo
@@ -39,7 +39,7 @@ escape()
39 echo $1 | sed -E 's/([][*])/\\\1/g' 39 echo $1 | sed -E 's/([][*])/\\\1/g'
40}40}
4141
42while getopts ":hps:b:t:B:wdT:" opt; do42while getopts ":hPs:b:t:B:wdT:" opt; do
43 case ${opt} in43 case ${opt} in
44 s)44 s)
45 if [ -d $OPTARG ]; then45 if [ -d $OPTARG ]; then
@@ -61,8 +61,8 @@ while getopts ":hps:b:t:B:wdT:" opt; do
61 B)61 B)
62 TARGET_GIT_BRANCH=$OPTARG62 TARGET_GIT_BRANCH=$OPTARG
63 ;;63 ;;
64 p)64 P)
65 GIT_PULL=165 GIT_PULL=0
66 ;;66 ;;
67 w)67 w)
68 WIDE_MODE=168 WIDE_MODE=1
@@ -87,27 +87,35 @@ shift $((OPTIND -1))
8787
88pwd="$PWD"88pwd="$PWD"
8989
90cd "$OEM_KERNEL_TREE"90cd "$target_repo"
91(91(
92git remote | grep -q mainline || (print_err "mainline remote missing in OEM kernel tree"; bye 1)92[ -n $TARGET_GIT_BRANCH ] && git checkout $TARGET_GIT_BRANCH
93git checkout $OEM_KERNEL_BRANCH
94[ $GIT_PULL = 1 ] && git pull --rebase93[ $GIT_PULL = 1 ] && git pull --rebase
95) 1>&294) 1>&2
95target_origin=`git remote get-url origin`
96target_head_hash=`git rev-parse --short HEAD`
97target_branch=`git branch --show-current`
9698
99cd "$OEM_KERNEL_TREE"
97(100(
98cd "$target_repo"101git remote | grep -q mainline || (print_err "mainline remote missing in OEM kernel tree"; bye 1)
99[ -n $TARGET_GIT_BRANCH ] && git checkout $TARGET_GIT_BRANCH102git checkout $OEM_KERNEL_BRANCH
103git fetch mainline
100[ $GIT_PULL = 1 ] && git pull --rebase104[ $GIT_PULL = 1 ] && git pull --rebase
101) 1>&2105) 1>&2
102106source_origin=`git remote get-url origin`
107source_head_hash=`git rev-parse --short HEAD`
108source_branch=`git branch --show-current`
103109
104FIRST_AND_LAST_HASH=( `git log --oneline -E --grep "UBUNTU: Ubuntu-[1-9]+" | sort -rV -k3 | awk 'NR==1 { print $1 }; END { print $1 }'` )110FIRST_AND_LAST_HASH=( `git log --oneline -E --grep "UBUNTU: Ubuntu-[1-9]+" | sort -rV -k3 | awk 'NR==1 { print $1 }; END { print $1 }'` )
105LATEST_UBUNTU_HASH=${FIRST_AND_LAST_HASH[0]}111LATEST_UBUNTU_HASH=${FIRST_AND_LAST_HASH[0]}
106EARLIEST_UBUNTU_HASH_DATE=`git log -1 --format=%aI ${FIRST_AND_LAST_HASH[1]}`112EARLIEST_UBUNTU_HASH_DATE=`git log -1 --format=%aI ${FIRST_AND_LAST_HASH[1]}`
107113
108printf "Report generated at "; date114printf "Report generated at "; date
115printf "Source: $source_origin $source_head_hash ($source_branch)\n"
116printf "Target: $target_origin $target_head_hash ($target_branch)\n"
109printf "T=Type: C=Cherry-pick, B=Backport, S=SAUCE patch, R=Revert, F=conFig\n"117printf "T=Type: C=Cherry-pick, B=Backport, S=SAUCE patch, R=Revert, F=conFig\n"
110printf "L=Landed in %s?\n" "${target_repo}"118printf "L=Landed?\n"
111printf " + Y=Landed, N=Not landed, M=Log messages differ but w/ identical patch contents\n"119printf " + Y=Landed, N=Not landed, M=Log messages differ but w/ identical patch contents\n"
112printf " + x%%=Commit with same log message found but patch contents differ\n"120printf " + x%%=Commit with same log message found but patch contents differ\n"
113perl -e 'print "-" x 180; print "\n"'121perl -e 'print "-" x 180; print "\n"'
diff --git a/hwe-bug-checker.py b/hwe-bug-checker.py
index 89fdbc5..ec8f51a 100755
--- a/hwe-bug-checker.py
+++ b/hwe-bug-checker.py
@@ -12,7 +12,7 @@ from launchpadlib.uris import lookup_service_root
1212
13APP_NAME = 'hwe-bug-checker'13APP_NAME = 'hwe-bug-checker'
14SERVICE_ROOT = 'production'14SERVICE_ROOT = 'production'
15HWE_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']15HWE_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']
1616
17logger = getLogger(APP_NAME)17logger = getLogger(APP_NAME)
1818
diff --git a/hwe-bug-monitor.py b/hwe-bug-monitor.py
index 2aff1cf..519776b 100755
--- a/hwe-bug-monitor.py
+++ b/hwe-bug-monitor.py
@@ -1,27 +1,38 @@
1#!/usr/bin/python31#!/usr/bin/python3
22
3import re
4
3from os import path5from os import path
4from subprocess import getoutput, getstatusoutput6from subprocess import getoutput, getstatusoutput
57
6HWE_BUG_CHECKER = '~/hwe-tools/hwe-bug-checker.py'8HWE_BUG_CHECKER = '~/hwe-tools/hwe-bug-checker.py'
7OEM_KERNELS = ['bionic git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/bionic oem-next',9OEM_KERNELS = ['focal git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/focal oem-5.14-next Ubuntu-oem-5.14',
8 'focal git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/focal oem-5.6-next',10 'jammy git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/jammy oem-5.17-next Ubuntu-oem-5.17']
9 'focal git://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/focal oem-5.10-next']
1011
11for kernel in OEM_KERNELS:12for kernel in OEM_KERNELS:
12 local = kernel.split(' ')[0]13 local = kernel.split(' ')[0]
13 repo = kernel.split(' ')[1]14 repo = kernel.split(' ')[1]
14 branch = kernel.split(' ')[2]15 branch = kernel.split(' ')[2]
16 tag_prefix = kernel.split(' ')[3]
15 print("%s %s %s" % (local, repo, branch))17 print("%s %s %s" % (local, repo, branch))
16 if not path.exists(local):18 if not path.exists(local):
17 getoutput("git clone --depth 1 --single-branch --branch %s %s %s" % (branch, repo, local))19 getoutput("git clone --depth 1 --single-branch --branch %s %s %s" % (branch, repo, local))
18 else:20 status, result = getstatusoutput("cd %s; git rev-parse --verify %s" % (local, branch))
19 status, result = getstatusoutput("cd %s; git rev-parse --verify %s" % (local, branch))21 if status != 0:
20 if status != 0:22 print("hwe-bug-checker: adding new branch - %s" % branch)
21 print("hwe-bug-checker: adding new branch - %s" % branch)23 getoutput("cd %s; git remote set-branches --add origin %s" % (local, branch))
22 getoutput("cd %s; git remote set-branches --add origin %s" % (local, branch))24 getoutput("cd %s; git remote set-branches origin %s" % (local, branch))
23 result = getoutput("(cd %s; git fetch origin)" % local)25 result = getoutput("(cd %s; git fetch origin)" % local)
24 if 'new tag' in result:26 for line in result.splitlines():
27 tag_pattern = re.compile(r" \* \[new tag\] +(.*) -> (.*)")
28 tag = tag_pattern.match(line)
29 if tag != None:
30 if tag_prefix not in tag[1]:
31 getoutput("cd %s; git tag -d %s" % (local, tag[1]))
32 continue
33 else:
34 continue
35
25 getoutput("(cd %s; git checkout -B %s origin/%s)" % (local, branch, branch))36 getoutput("(cd %s; git checkout -B %s origin/%s)" % (local, branch, branch))
26 result = getoutput("(cd %s; %s)" % (local, HWE_BUG_CHECKER))37 result = getoutput("(cd %s; %s)" % (local, HWE_BUG_CHECKER))
27 print("hwe-bug-checker: %s" % result)38 print("hwe-bug-checker: %s" % result)

Subscribers

People subscribed via source and target branches

to all changes: