def pull_request(): args = _make_argparser().parse_args() if args.debug: logging.disable(logging.NOTSET) try: git = Git() except GitException as ex: print('ERROR: ' + ex.message) return 1 config = CmdprConfig(CONFIG) try: github = GitHub(get_token(config)) base = args.base[0] title, body = '', '' if args.message is None: title, body = create_request_title(git.get_commits(base)) else: title = args.message[0] if title is None: print('ERROR: There\'s no title for pull request') return 1 repo_info = git.get_repo_info() bug_tracker = config.get("bug_tracker") if bug_tracker: body = bug_tracker.format(task=repo_info['branch']) pr_url = github.create_pull_request(repo_info, title, base, body) print(pr_url) except GitHubException as ex: print('ERROR: ' + ex.message) return 1