Created
November 26, 2022 13:10
-
-
Save MarcoGorelli/ed6249f88644d89254ec1bf5f85405cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import subprocess | |
import re | |
import shlex | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('command') | |
parser.add_argument('action', choices=['pull', 'push']) | |
args = parser.parse_args() | |
branch = args.command.split()[-1] | |
remote = args.command.split()[2] | |
user = re.search(r'git@github.com:(.*)/pandas.git', args.command).group(1) | |
if args.action == 'pull': | |
subprocess.run(['git', 'checkout', '-b', f'pr/{user}/{branch}']) | |
subprocess.run(['git', 'checkout', f'pr/{user}/{branch}']) | |
subprocess.run(['git', 'pull', remote, branch]) | |
subprocess.run(['git', 'reset', '--hard', 'FETCH_HEAD']) | |
else: | |
subprocess.run(['git', 'push', remote, f'HEAD:{branch}']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment