Skip to content

Commit

Permalink
git push via https now works
Browse files Browse the repository at this point in the history
  • Loading branch information
bsclifton committed Feb 25, 2019
1 parent 9bca711 commit 7e97d17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions script/lib/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,19 @@ def get_title_from_first_commit(path, branch_to_compare):
return title_list[0]


def push_branches_to_remote(path, branches_to_push, dryrun=False):
def push_branches_to_remote(path, branches_to_push, dryrun=False, token=None):
if dryrun:
print('[INFO] would push the following local branches to remote: ' + str(branches_to_push))
else:
with scoped_cwd(path):
for branch_to_push in branches_to_push:
print('- pushing ' + branch_to_push + '...')
# TODO: if they already exist, force push?? or error??
# NOTE: this fails if clone was done via https
execute(['git', 'push', '-u', 'origin', branch_to_push])
response = execute(['git', 'remote', 'get-url', '--push', 'origin']).strip()
if response.startswith('https://'):
if len(str(token)) == 0:
raise Exception('GitHub token cannot be null or empty!')
remote = response.replace('https://', 'https://' + token + ':x-oauth-basic@')
execute(['git', 'push', '-u', remote, branch_to_push])
else:
execute(['git', 'push', '-u', 'origin', branch_to_push])
2 changes: 1 addition & 1 deletion script/pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def main():
return 1

print('\nPushing local branches to remote...')
push_branches_to_remote(BRAVE_CORE_ROOT, config.branches_to_push, dryrun=config.is_dryrun)
push_branches_to_remote(BRAVE_CORE_ROOT, config.branches_to_push, dryrun=config.is_dryrun, token=config.github_token)

try:
print('\nCreating the pull requests...')
Expand Down

0 comments on commit 7e97d17

Please sign in to comment.