Skip to content
Merged
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
8 changes: 8 additions & 0 deletions acp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions test_acp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading