Created
February 19, 2014 14:24
-
-
Save CraZySacX/9093122 to your computer and use it in GitHub Desktop.
Python script that aids with merging upstream projects with origin. Useful for github forks.
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
#!/usr/bin/python3 | |
import argparse | |
import os | |
from os import environ | |
from subprocess import check_call | |
# Store the current directory | |
owd = os.getcwd() | |
# Setup the supported command-line arguments | |
parser = argparse.ArgumentParser(description='Useful for merging upstream branches') | |
parser.add_argument('-d', '--dir', default=str(environ['HOME'] + "/projects")) | |
parser.add_argument('-p', '--project', required=True) | |
parser.add_argument('-b', '--branch', nargs='+') | |
parser.add_argument('-u', '--upstream', default='upstream') | |
# Parse the command-line arguments | |
args = parser.parse_args() | |
# Change working directory | |
os.chdir(str(args.dir + "/" + args.project)) | |
# Checkout and merge each branch | |
for b in args.branch: | |
check_call(["git", "checkout", str(b)]) | |
check_call(["git", "merge", args.upstream + "/" + str(b)]) | |
# Push all the merges | |
check_call(["git", "push", "--all"]) | |
# Change back to the original directory | |
os.chdir(owd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
merger.py -p v8 -b bleeding_edge master