pr submit: prefer default-push when pushing commits

Summary: If a user cloned the upstream repo then added their fork as "default-push", we would still try pushing commits to the "default" upstream repo. With this change, we prefer "default-push" when pushing commits.

Reviewed By: zzl0

Differential Revision: D43919071

fbshipit-source-id: fc1ab73ba8ff0b5aee3e34fdf92f8969b9269650
This commit is contained in:
Muir Manders 2023-03-13 21:33:40 -07:00 committed by Facebook GitHub Bot
parent 6c558fc4e4
commit b31704fa68
2 changed files with 14 additions and 4 deletions

View File

@ -113,7 +113,17 @@ subcmd = pull_request_command.subcommand(
],
)
def submit_cmd(ui, repo, *args, **opts):
"""create or update GitHub pull requests from local commits"""
"""create or update GitHub pull requests from local commits
Commit(s) will be pushed to ``default-push``, if configured, else
``default`` (see :prog:`help urls` and :prog:`help path`).
Pull request(s) will be created against ``default``. If
``default`` is a fork, they will be created against default's
upstream repository.
Returns 0 on success.
"""
return submit.submit(ui, repo, *args, **opts)

View File

@ -160,7 +160,7 @@ async def update_commits_in_stack(
if not partitions:
ui.status_err(_("no commits to submit\n"))
return 0
origin = get_origin(ui)
origin = get_push_origin(ui)
use_placeholder_strategy = ui.configbool("github", "placeholder-strategy")
if use_placeholder_strategy:
params = await create_placeholder_strategy_params(
@ -612,12 +612,12 @@ async def get_repository_for_origin(origin: str, hostname: str) -> Repository:
return await get_repo(hostname, origin_owner, origin_name)
def get_origin(ui) -> str:
def get_push_origin(ui) -> str:
test_url = os.environ.get("SL_TEST_GH_URL")
if test_url:
origin = test_url
else:
origin = ui.config("paths", "default")
origin = ui.expandpath("default-push", "default")
if origin:
return origin
else: