Skip to content

Instantly share code, notes, and snippets.

@pascalchevrel
Created September 18, 2023 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pascalchevrel/4d983e3ad9d4f52acccf3d141fe8a838 to your computer and use it in GitHub Desktop.
Save pascalchevrel/4d983e3ad9d4f52acccf3d141fe8a838 to your computer and use it in GitHub Desktop.
List backports on branch X that were not cherrypicked in branch X+1
#!/usr/bin/env python3
# usage: backports.py 117
import os
import sys
version = sys.argv[1]
# Create a list of commits not merged directly in the version +1 branch
myCmd = "git log --no-merges release/v" + version + " ^release/v" + str((int(version) + 1)) + " | grep cherry | awk '{print " " $5}' | awk '{print substr($1, 1, length($1)-1)}'"
# Clean up and put in a list
commits = os.popen(myCmd).read().split("\n")
commits = list(filter(None, commits))
for item in commits:
# Get the originating cherrypicked branch
val = os.popen('git branch --contains ' + item).read();
# If there is no originating branch, we need to check manually the backport
if not val:
output = os.popen('git show --oneline --no-patch ' + item).read()
print(output, end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment