def get_open_pr(self): ret = self._cache.get('pr') if ret is not None: return ret branch = str(Helper.current_branch()) prs = self._api.call('list_pr', owner=self._owner, repo=self._repo, data={ 'head': branch })[0] for pr in prs: if pr['head']['ref'] == branch: self._cache['pr'] = pr return pr return None
from GithubAPIGateway import GithubAPIGateway import Helper import os import sys import argparse import webbrowser parser = argparse.ArgumentParser() parser.add_argument("-o", "--open", action="store_true") args = parser.parse_args() api = GithubAPIGateway(token=os.environ['GITHUB_TOKEN']) owner, repo = Helper.owner_and_repo() branch = str(Helper.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 args.open: webbrowser.open(url) else: print "No PRs on this branch"
import Helper import re import webbrowser branch = Helper.current_branch() match = re.search('^(\d+)\-', branch) issue = None if match is not None: owner, repo = Helper.owner_and_repo() webbrowser.open('https://github.com/{0}/{1}/issues/{2}'.format(owner, repo, match.group(1))) else: print 'No issue number on branch'
def get_builds(self): branch = Helper.current_branch() return self._api.call('recent_branch_builds', username=self._username, project=self._project, branch=branch)[0]