def _get_github_url(repo=None): feature_config = feature.configuration(repo) target_remote_url = get_remote_url(feature_config.target_remote, repo) if 'github.com' not in target_remote_url: return 'https://%s/api/v3' % target_remote_url.split('@')[1].split(':')[0] else: return DEFAULT_BASE_URL
def _push(): repo = get_repo() check_repo_is_clean(repo) feature_config = feature.configuration(repo) base = '%s/%s' % (feature_config.working_remote, feature_config.target_branch) if repo.head.commit == repo.commit(base): raise CommandException('You are currently at %s, there is nothing to push' % base) commit_message = repo.head.commit.message repo.git.reset('--soft', 'HEAD^') repo.git.stash('save', _escape_new_lines(commit_message))
def _create_pull_request(repo): feature_config = feature.configuration(repo) target_remote = feature_config.target_remote working_remote = feature_config.working_remote target_branch = feature_config.target_branch full_repo_name = get_remote_url(target_remote, repo).split(':')[1].split('.')[0] working_namespace = get_remote_url(working_remote, repo).split(':')[1].split('/')[0] current_branch = get_current_branch(repo) head = '%s:%s' % (working_namespace, current_branch) if target_remote is working_remote: if current_branch is target_branch: raise CommandException("Unable to create a pull request from the same remote and branch.") head = current_branch pull_request = { 'title': repo.head.commit.summary, 'body': repo.head.commit.message, 'head': head, 'base': target_branch } logging.debug('Creating pull request with: %s' % pull_request) return _get_github(repo).get_repo(full_repo_name).create_pull(**pull_request)