Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions eden/scm/sapling/ext/github/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ def from_config(ui) -> "SubmitWorkflow":
workflow = ui.config(
"github", "pr-workflow", ui.config("github", "pr_workflow")
)
if not workflow or workflow == "overlap":
# For now, default to OVERLAP.
return SubmitWorkflow.OVERLAP
elif workflow == "single":
if not workflow or workflow == "single":
# Default to SINGLE.
return SubmitWorkflow.SINGLE
elif workflow == "overlap":
return SubmitWorkflow.OVERLAP
else:
# Note that "classic" is not recognized yet.
ui.warn(
_("unrecognized config for github.pr_workflow: defaulting to 'overlap'")
)
return SubmitWorkflow.OVERLAP
return SubmitWorkflow.SINGLE


@dataclass
Expand Down Expand Up @@ -160,8 +160,6 @@ async def update_commits_in_stack(

store = PullRequestStore(repo)

workflow = SubmitWorkflow.from_config(ui)

partitions = await get_partitions(ui, repo, store, "sort(. %% public(), -rev)")
if not partitions:
ui.status_err(_("no commits to submit\n"))
Expand Down Expand Up @@ -211,6 +209,14 @@ def get_gitdir() -> str:
return 0

repository = params.repository
if not repository:
repository = await get_repository_for_origin(origin, github_repo.hostname)

if repository.upstream is not None:
# Always use OVERLAP workflow for forked repositories
workflow = SubmitWorkflow.OVERLAP
else:
workflow = SubmitWorkflow.from_config(ui)

# For the SINGLE workflow, we must update the base branch on existing PRs
# BEFORE pushing the new branch contents. Otherwise, when commits are
Expand All @@ -223,10 +229,6 @@ def get_gitdir() -> str:
p for p in partitions if p[0].pr and p[0].pr.state == PullRequestState.OPEN
]
if existing_prs:
if not repository:
repository = await get_repository_for_origin(
origin, github_repo.hostname
)
# Update base branches on existing PRs before pushing.
# Process from bottom of stack to top so bases are set correctly.
for index in range(len(partitions)):
Expand Down Expand Up @@ -254,8 +256,6 @@ def get_gitdir() -> str:
run_git_command(git_push_args, gitdir)

if params.pull_requests_to_create:
if not repository:
repository = await get_repository_for_origin(origin, github_repo.hostname)
if use_placeholder_strategy:
assert isinstance(params, PlaceholderStrategyParams)
await create_pull_requests_from_placeholder_issues(
Expand Down Expand Up @@ -286,8 +286,6 @@ def get_gitdir() -> str:
# Add the head of the stack to the sapling-pr-archive branch.
tip = hex(partitions[0][0].node)

if not repository:
repository = await get_repository_for_origin(origin, github_repo.hostname)
rewrite_and_archive_requests = [
rewrite_pull_request_body(
partitions, index, workflow, pr_numbers_and_num_commits, repository, ui
Expand Down
2 changes: 1 addition & 1 deletion eden/scm/tests/github/mock_create_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setup_mock_github_server(ui) -> MockGitHubServer:
(43, "two\n"),
]

single = ui.config("github", "pr-workflow") == "single"
single = ui.config("github", "pr-workflow") != "overlap"

for idx, (num, msg) in enumerate(prs):
title, body = title_and_body(msg)
Expand Down
2 changes: 1 addition & 1 deletion eden/scm/tests/test-ext-github-pr-submit-closed.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$ enable github
$ export SL_TEST_GH_URL=https://github.com/facebook/test_github_repo.git
$ . $TESTDIR/git.sh
$ configure github.pr-workflow=single
$ setconfig github.pr-workflow=single

build up a github repo

Expand Down
2 changes: 1 addition & 1 deletion eden/scm/tests/test-ext-github-pr-submit-open.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Test that `sl pr submit --open` opens created PRs in the browser.
$ enable github
$ export SL_TEST_GH_URL=https://github.com/facebook/test_github_repo.git
$ . $TESTDIR/git.sh
$ configure github.pr-workflow=overlap
$ setconfig github.pr-workflow=overlap

build up a github repo

Expand Down
2 changes: 1 addition & 1 deletion eden/scm/tests/test-ext-github-pr-submit-overlap.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$ enable github
$ export SL_TEST_GH_URL=https://github.com/facebook/test_github_repo.git
$ . $TESTDIR/git.sh
$ configure github.pr-workflow=overlap
$ setconfig github.pr-workflow=overlap

build up a github repo

Expand Down
2 changes: 1 addition & 1 deletion eden/scm/tests/test-ext-github-pr-submit-single.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$ enable github
$ export SL_TEST_GH_URL=https://github.com/facebook/test_github_repo.git
$ . $TESTDIR/git.sh
$ configure github.pr-workflow=single
$ setconfig github.pr-workflow=single

build up a github repo

Expand Down
Loading