From d0a256a960a52ea02955df0c794edb28b782fb8d Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 18 May 2026 13:17:12 +0300 Subject: [PATCH] feat: prohibit creation of new PRs from acp/ branches --- acp.py | 8 ++++++++ test_acp.py | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/acp.py b/acp.py index baeff3b..5b09015 100755 --- a/acp.py +++ b/acp.py @@ -656,6 +656,14 @@ def create_pr( if verbose: print(f"Current branch: '{original_branch}'") + if original_branch.startswith("acp/"): + print( + f"Error: Already on an ACP branch '{original_branch}'. " + "Switch to your base branch before creating a new PR.", + file=sys.stderr, + ) + sys.exit(1) + if run_check(["git", "diff", "--cached", "--quiet"]): print("Error: No staged changes. Run 'git add' first.", file=sys.stderr) sys.exit(1) diff --git a/test_acp.py b/test_acp.py index 5975fef..17395ae 100644 --- a/test_acp.py +++ b/test_acp.py @@ -38,6 +38,16 @@ def test_run_check_failure(self): class TestCreatePR: + @mock.patch("acp.run") + @mock.patch("acp.run_check") + def test_create_pr_on_acp_branch(self, mock_run_check, mock_run, capsys): + mock_run.return_value = "acp/testuser/1234567890123456" + + with pytest.raises(SystemExit) as exc: + acp.create_pr("test commit", verbose=False, body="") + assert exc.value.code == 1 + assert "Already on an ACP branch" in capsys.readouterr().err + @mock.patch("acp.run") @mock.patch("acp.run_check") def test_create_pr_no_staged_changes(self, mock_run_check, mock_run):