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
This commit is contained in:
Thomas Haller 2020-11-24 11:54:17 +01:00
parent 0f26529bb3
commit 87749642e2
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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