Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c9c5a31 authored by Harry Youd's avatar Harry Youd Committed by Michael W
Browse files

repopick: Add 'reset' option

In case of conflict, reset to initial state by aborting the cherry-pick,
leaving the working directory clean

Change-Id: I2353b92254b67ea49835bc88b6fc9bc3910b5107
parent 296008cc
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ if __name__ == '__main__':
    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')
@@ -408,6 +409,11 @@ if __name__ == '__main__':
                cmd_out = None
            result = subprocess.call(cmd, cwd=project_path, shell=True, stdout=cmd_out, stderr=cmd_out)
            if result != 0:
                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: