From 87749642e2c0e0233af35a8121c4ccc6c1190363 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 24 Nov 2020 11:54:17 +0100 Subject: [PATCH] scripts: allow marking commits with "Ignore-Backport:" in "find-backports" script "find-backports" searches commit messages of upstream branches for "Fixes:" comments. Those will then be highlighted to be backported, if the script determines that to be necessary. "find-backports" also honors the "cherry picked from" comments, to detect when a patch was already backported. That is thus a way to suppress reporting a commit to be backported. Add another way to flag commits so they don't need backporting. Via "Ignore-Backport:" tag. As "find-backports" also honors "refs/notes/bugs" notes, this can be used like: git notes \ --ref refs/notes/bugs \ append \ -m "Ignore-Backport: e""29f00fa0c69 ('NEWS: fix entry that is targeted for 1.30 instead of 1.28')" \ 2''3364aa8f3bd6b11e2ac9e30117eaabfe1f3a9f2 --- contrib/scripts/find-backports | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/contrib/scripts/find-backports b/contrib/scripts/find-backports index 6cb62dcea6..7f1b8ab8dd 100755 --- a/contrib/scripts/find-backports +++ b/contrib/scripts/find-backports @@ -151,7 +151,7 @@ def git_ref_commit_body(ref): def git_ref_commit_body_get_fixes(ref): body = git_ref_commit_body(ref) result = [] - for mo in re.finditer(re_bin("[fF]ixes: *([0-9a-z]+).*"), body): + for mo in re.finditer(re_bin("\\b[fF]ixes: *([0-9a-z]+)\\b"), body): c = mo.group(1).decode("ascii") h = git_ref_exists(c) if h: @@ -166,16 +166,18 @@ def git_ref_commit_body_get_cherry_picked_one(ref): return None body = git_ref_commit_body(ref) result = None - for mo in re.finditer( - re_bin(".*\(cherry picked from commit ([0-9a-z]+)\).*"), body - ): - c = mo.group(1).decode("ascii") - h = git_ref_exists(c) - if h: - if not result: - result = [h] - else: - result.append(h) + for r in [ + re_bin("\(cherry picked from commit ([0-9a-z]+)\)"), + re_bin("\\bIgnore-Backport: *([0-9a-z]+)\\b"), + ]: + for mo in re.finditer(r, body): + c = mo.group(1).decode("ascii") + h = git_ref_exists(c) + if h: + if not result: + result = [h] + else: + result.append(h) return result