From 6e983b14e29104731f24364ccdcc7be1a4aff406 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 01:12:36 +0000 Subject: [PATCH 1/2] Initial plan From 3ae1d2801f4d5b5f89d322f389c422f3582df855 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 01:14:28 +0000 Subject: [PATCH 2/2] Add origin/master fallback to ready_to_make_pr upstream ref lookup The upstream fork point detection in safe-output-create-pr.md only checked @{upstream}, origin/HEAD, and origin/main. Repos with master as the default branch would fail when local tracking was unset and origin/HEAD was unavailable. Add origin/master to the fallback list and add a test for this scenario. Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com> --- .../gh-aw-fragments/safe-output-create-pr.md | 2 +- tests/test_safe_input_ready_to_make_pr.py | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gh-aw-fragments/safe-output-create-pr.md b/.github/workflows/gh-aw-fragments/safe-output-create-pr.md index 51358737..467d1f97 100644 --- a/.github/workflows/gh-aw-fragments/safe-output-create-pr.md +++ b/.github/workflows/gh-aw-fragments/safe-output-create-pr.md @@ -15,7 +15,7 @@ safe-inputs: # Guard: detect merge commits # Find the fork point with the upstream branch to scope the check upstream_sha = '' - for ref in ['@{upstream}', 'origin/HEAD', 'origin/main']: + for ref in ['@{upstream}', 'origin/HEAD', 'origin/main', 'origin/master']: r = run(['git', 'merge-base', 'HEAD', ref]) if r.returncode == 0 and r.stdout.strip(): upstream_sha = r.stdout.strip() diff --git a/tests/test_safe_input_ready_to_make_pr.py b/tests/test_safe_input_ready_to_make_pr.py index adf1e964..e613bb55 100644 --- a/tests/test_safe_input_ready_to_make_pr.py +++ b/tests/test_safe_input_ready_to_make_pr.py @@ -556,6 +556,51 @@ def test_merge_commit_detected(self, py_code, tmp_path): assert output["status"] == "error" assert "Merge commit" in output["error"] + def test_origin_master_fallback(self, py_code, tmp_path): + """origin/master should be used when upstream and origin/HEAD are unavailable.""" + repo = tmp_path / "repo" + repo.mkdir() + + def git(*args): + subprocess.run( + ["git"] + list(args), + cwd=str(repo), + capture_output=True, + check=True, + ) + + # Create a repo with 'master' as default branch + git("init", "-b", "master") + git("config", "user.email", "test@test.com") + git("config", "user.name", "Test") + (repo / "file.txt").write_text("hello\n") + git("add", "file.txt") + git("commit", "-m", "init") + + # Set up a bare remote and push + remote = tmp_path / "remote.git" + subprocess.run( + ["git", "clone", "--bare", str(repo), str(remote)], + capture_output=True, + check=True, + ) + git("remote", "add", "origin", str(remote)) + git("fetch", "origin") + + # Do NOT set upstream tracking and remove origin/HEAD + subprocess.run( + ["git", "-C", str(repo), "remote", "set-head", "origin", "--delete"], + capture_output=True, + ) + + # Make a new commit so there's a diff + (repo / "new.txt").write_text("new\n") + git("add", "new.txt") + git("commit", "-m", "add new") + + output = run_py_in_repo(py_code, str(repo)) + assert output["status"] == "ok" + def test_no_upstream_fails_closed(self, py_code, tmp_path): """Without an upstream ref, the create guard should fail closed.""" repo = make_git_repo(tmp_path, with_upstream=False)