Skip to content

Commit

Permalink
repopick: Add 'reset' option
Browse files Browse the repository at this point in the history
In case of conflict, reset to initial state by aborting the cherry-pick,
leaving the working directory clean

Change-Id: I2353b92254b67ea49835bc88b6fc9bc3910b5107
  • Loading branch information
harryyoud authored and Miccia94 committed Aug 9, 2017
1 parent 9d0078d commit 8f7fc91
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/repopick.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def fetch_query(remote_url, query):
parser.add_argument('change_number', nargs='*', help='change number to cherry pick. Use {change number}/{patchset number} to get a specific revision.')
parser.add_argument('-i', '--ignore-missing', action='store_true', help='do not error out if a patch applies to a missing directory')
parser.add_argument('-s', '--start-branch', nargs=1, help='start the specified branch before cherry picking')
parser.add_argument('-r', '--reset', action='store_true', help='reset to initial state (abort cherry-pick) if there is a conflict')
parser.add_argument('-a', '--abandon-first', action='store_true', help='before cherry picking, abandon the branch specified in --start-branch')
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')
Expand Down Expand Up @@ -403,7 +404,12 @@ def fetch_query(remote_url, query):
cmd_out = None
result = subprocess.call(cmd, cwd=project_path, shell=True, stdout=cmd_out, stderr=cmd_out)
if result != 0:
print('ERROR: git command failed')
if args.reset:
print('ERROR: git command failed, aborting cherry-pick')
cmd = ['git cherry-pick --abort']
subprocess.call(cmd, cwd=project_path, shell=True, stdout=cmd_out, stderr=cmd_out)
else:
print('ERROR: git command failed')
sys.exit(result)
if not args.quiet:
print('')

0 comments on commit 8f7fc91

Please sign in to comment.