forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-gh-pr.py
executable file
·24 lines (22 loc) · 1.32 KB
/
create-gh-pr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
from github import Github
from os.path import expanduser
from sys import argv , exit
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument("-r", "--repository", dest="repo", help="Github Repositoy name e.g cms-sw/cms-bot",type=str)
parser.add_argument("-b", "--base_branch", dest="base_branch",help="Repository branch againt which new Pull request should be created",type=str)
parser.add_argument("-f", "--feature_branch", dest="feature_branch",help="New feature branch to be merged",type=str)
parser.add_argument("-t", "--title", dest="title", help="Pull request title",type=str)
parser.add_argument("-d", "--body", dest="body", help="Pull request body text, optional",type=str, default='')
args = parser.parse_args()
if not args.repo: parser.error("Missing Repo")
if not args.base_branch: parser.error("Missing base branch name.")
if not args.feature_branch: parser.error("Missing feature branch name.")
if not args.title: parser.error("Missing PR title")
print "Authenticating to Github and connecting to repo"
gh = Github(login_or_token = open(expanduser("~/.github-token")).read().strip())
print "Authentication succeeeded"
gh_repo = gh.get_repo(args.repo)
print "Creating pull request"
gh_repo.create_pull(title = args.title, body = args.body, base = args.base_branch, head = args.feature_branch)