summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-04-06 18:24:29 +0200
committerThomas Haller <thaller@redhat.com>2023-04-06 21:37:10 +0200
commit65ef6bc9bc853656899a6dd54348e72ba5d44aef (patch)
treee118acabb027b1fa0308b73e4357d8952c4fa87d
parent9f899108523ce3ad3212ee443d8bc7edeb61a386 (diff)
downloadNetworkManager-65ef6bc9bc853656899a6dd54348e72ba5d44aef.tar.gz
find-backports: warn if any commits are not from the first reference
Every branch (for example "nm-1-40") has exactly one next branch, from which patches should be backported (in that example that branch is "nm-1-42"). While "find-backports" searches all newer branches for patches, it does not make it clear form where the patch should come from. That means, if you run the script `contrib/scripts/find-backports origin/nm-1-40` it will check nm-1-42 and main branch, and might suggest to backport patches that are only on main, but not "nm-1-42". That would be wrong, because patches need to first go into nm-1-42, and then backported (from there) further to nm-1-40. Print a warning to highlight that.
-rwxr-xr-xcontrib/scripts/find-backports26
1 files changed, 26 insertions, 0 deletions
diff --git a/contrib/scripts/find-backports b/contrib/scripts/find-backports
index 7b8d94456d..6d2500c946 100755
--- a/contrib/scripts/find-backports
+++ b/contrib/scripts/find-backports
@@ -139,6 +139,11 @@ def git_all_commits(rnge):
return git_all_commits_grep(rnge)
+@memoize
+def git_all_commits_set(rnge):
+ return set(git_all_commits_grep(rnge))
+
+
def git_commit_sorted(commits):
commits = list(commits)
if not commits:
@@ -256,6 +261,10 @@ def git_commits_annotate_cherry_picked(rnge):
return c_dict
+def git_ref_in_history(ref, rnge):
+ return git_ref_exists(ref) in git_all_commits_set(rnge)
+
+
if __name__ == "__main__":
if len(sys.argv) <= 1:
ref_head0 = "HEAD"
@@ -371,5 +380,22 @@ if __name__ == "__main__":
print_err(git_logg(commits_good))
+ not_in = [
+ c
+ for c in commits_good
+ if not git_ref_in_history(c, f"{ref_head}..{ref_upstreams[0]}")
+ ]
+ if not_in:
+ print_err("")
+ print_err(
+ f'WARNING: The following commits are not from the first reference "{ref_upstreams[0]}".'
+ )
+ print_err(
+ f' You may want to first backports those patches to "{ref_upstreams[0]}".'
+ )
+ for l in git_logg(git_commit_sorted(not_in)).splitlines():
+ print_err(f" - {l}")
+ print_err("")
+
for c in reversed(commits_good):
print("%s" % (c))