Skip to content
This repository was archived by the owner on Nov 28, 2024. It is now read-only.

Commit 75aaac7

Browse files
authored
Merge pull request #71 from jd/always-prefix-branch
Always prefix remote branch when not forking
2 parents 870a1a0 + 0916005 commit 75aaac7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

git_pull_request/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,11 @@ def fork_and_push_pull_request(g, hosttype, repo_to_fork, rebase,
443443
remote_to_push, repo_forked.clone_url])
444444
LOG.info("Added forked repository as remote `%s'", remote_to_push)
445445
head = "{}:{}".format(user, branch)
446+
remote_branch = branch
446447
else:
448+
remote_branch = "{}/{}".format(g_user.login, branch)
447449
remote_to_push = target_remote
448-
head = "{}:{}".format(repo_to_fork.owner.login, branch)
450+
head = "{}:{}".format(repo_to_fork.owner.login, remote_branch)
449451

450452
if setup_only:
451453
LOG.info("Fetch existing branches of remote `%s`", remote_to_push)
@@ -476,10 +478,14 @@ def fork_and_push_pull_request(g, hosttype, repo_to_fork, rebase,
476478
"resolved.")
477479
return 37
478480

479-
LOG.info("Force-pushing branch `%s' to remote `%s'",
480-
branch, remote_to_push)
481+
LOG.info("Force-pushing branch `%s' to remote `%s/%s'",
482+
branch, remote_to_push, remote_branch)
481483

482-
_run_shell_command(["git", "push", "-f", remote_to_push, branch])
484+
_run_shell_command([
485+
"git", "push", "-f",
486+
remote_to_push,
487+
"{}:{}".format(branch, remote_branch),
488+
])
483489

484490
pulls = list(repo_to_fork.get_pulls(base=target_branch,
485491
head=head))

0 commit comments

Comments
 (0)