Skip to content

Commit

Permalink
repopick: skip a cherry pick if its already been merged
Browse files Browse the repository at this point in the history
* override this behavior with the -f argument

Change-Id: I280b4945344e7483a192d1c9769c42b8fd2a2aef
  • Loading branch information
invisiblek authored and Gerrit Code Review committed Oct 1, 2013
1 parent 6ddf0d0 commit ed62c41
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/repopick.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
parser.add_argument('-b', '--auto-branch', action='store_true', help='shortcut to "--start-branch auto --abandon-first --ignore-missing"')
parser.add_argument('-q', '--quiet', action='store_true', help='print as little as possible')
parser.add_argument('-v', '--verbose', action='store_true', help='print extra information to aid in debug')
parser.add_argument('-f', '--force', action='store_true', help='force cherry pick even if commit has been merged')
args = parser.parse_args()
if args.start_branch == None and args.abandon_first:
parser.error('if --abandon-first is set, you must also give the branch name with --start-branch')
Expand Down Expand Up @@ -217,6 +218,7 @@ def is_pathA_subdir_of_pathB(pathA, pathB):
date_fluff = '.000000000'
project_name = data['project']
change_number = data['_number']
status = data['status']
current_revision = data['revisions'][data['current_revision']]
patch_number = current_revision['_number']
fetch_url = current_revision['fetch']['http']['url']
Expand All @@ -229,6 +231,14 @@ def is_pathA_subdir_of_pathB(pathA, pathB):
committer_date = current_revision['commit']['committer']['date'].replace(date_fluff, '')
subject = current_revision['commit']['subject']

# Check if commit has already been merged and exit if it has, unless -f is specified
if status == "MERGED":
if args.force:
print("!! Force-picking a merged commit !!\n")
else:
print("Commit already merged. Skipping the cherry pick.\nUse -f to force this pick.")
sys.exit(1)

# Convert the project name to a project path
# - check that the project path exists
if project_name in project_name_to_path:
Expand Down

0 comments on commit ed62c41

Please sign in to comment.