def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-d", "--description") parser.add_argument("-n", "--nobranch", action="store_true") parser.add_argument("title") args = parser.parse_args() if len(args.title) < 5: print "The title should be 5 characters or longer" parser.print_usage() sys.exit(2) owner, repo = Helper.owner_and_repo() api = GithubAPIGateway(owner, repo, token=os.environ['GITHUB_TOKEN']) username = api.call('user')[0]['login'] data = { 'title': args.title, 'assignee': username } if args.description is not None: data.update(body=args.description) issue = api.call('create_issue', owner=owner, repo=repo, data=data)[0] print issue['html_url'] branch_name = Helper.branch_name(issue) if args.nobranch == False: Helper.create_branch(branch_name) else: print branch_name
def run(): h2 = Helper2() owner, repo = h2.owner_and_repo() api = GithubAPIGateway(owner, repo, token=os.environ['GITHUB_TOKEN']) issue = None if len(sys.argv) <= 1: issue = api.call('list_issues', org=owner)[0][0] else: issue = api.call('list_issue', owner=owner, repo=repo, number=sys.argv[1])[0] branch_name = str(issue['number']) + '-' + inflection.parameterize(issue['title'])[:30].strip('-') result = h2.create_branch(branch_name) if result[0] != 0: print(result[1]) sys.exit(result[0])
def __init__(self, args, issue_number): super(IssueHandler, self).__init__(args) self.issue_number = issue_number owner, repo = Helper.owner_and_repo() api = GithubAPIGateway(owner, repo, token=os.environ['GITHUB_TOKEN']) result = api.call('list_issue', owner=owner, repo=repo, number=issue_number) if result[1] != 200: raise ObjectNotFoundException('issue', issue_number) else: self.obj = result[0]
def run(): parser = argparse.ArgumentParser(prog = get_script_name_from_python_file(__file__)) parser.add_argument("-l", "--list-only", action="store_true") args = parser.parse_args() h2 = Helper2() owner, repo = h2.owner_and_repo() api = GithubAPIGateway(owner, repo, token=os.environ['GITHUB_TOKEN']) branch = str(h2.current_branch()) prs = api.call('list_pr', owner=owner, repo=repo, data={ 'head': branch })[0] url = None for pr in prs: if pr['head']['ref'] == branch: url = pr['html_url'] break if url is not None: print url if not args.list_only: webbrowser.open(url) else: print "No PRs on this branch"