diff --git a/eden/scm/sapling/ext/github/submit.py b/eden/scm/sapling/ext/github/submit.py index 423bdaff16bcf..b502359956847 100644 --- a/eden/scm/sapling/ext/github/submit.py +++ b/eden/scm/sapling/ext/github/submit.py @@ -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 @@ -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")) @@ -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 @@ -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)): @@ -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( @@ -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 diff --git a/eden/scm/tests/github/mock_create_prs.py b/eden/scm/tests/github/mock_create_prs.py index 2bd5cd653b503..64523a34afe50 100644 --- a/eden/scm/tests/github/mock_create_prs.py +++ b/eden/scm/tests/github/mock_create_prs.py @@ -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) diff --git a/eden/scm/tests/test-ext-github-pr-submit-closed.t b/eden/scm/tests/test-ext-github-pr-submit-closed.t index cf4244c465667..ea5af78c403be 100644 --- a/eden/scm/tests/test-ext-github-pr-submit-closed.t +++ b/eden/scm/tests/test-ext-github-pr-submit-closed.t @@ -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 diff --git a/eden/scm/tests/test-ext-github-pr-submit-open.t b/eden/scm/tests/test-ext-github-pr-submit-open.t index 3d5a2ee37b5d9..215868b0694f3 100644 --- a/eden/scm/tests/test-ext-github-pr-submit-open.t +++ b/eden/scm/tests/test-ext-github-pr-submit-open.t @@ -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 diff --git a/eden/scm/tests/test-ext-github-pr-submit-overlap.t b/eden/scm/tests/test-ext-github-pr-submit-overlap.t index eeac14c337fe0..eeab63272e6af 100644 --- a/eden/scm/tests/test-ext-github-pr-submit-overlap.t +++ b/eden/scm/tests/test-ext-github-pr-submit-overlap.t @@ -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 diff --git a/eden/scm/tests/test-ext-github-pr-submit-single.t b/eden/scm/tests/test-ext-github-pr-submit-single.t index b9e4d8fd527a6..7cc8746e667ad 100644 --- a/eden/scm/tests/test-ext-github-pr-submit-single.t +++ b/eden/scm/tests/test-ext-github-pr-submit-single.t @@ -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