diff --git a/bin/chunk_pr/main.py b/bin/chunk_pr/main.py index 4b05facb..4513989e 100644 --- a/bin/chunk_pr/main.py +++ b/bin/chunk_pr/main.py @@ -120,6 +120,7 @@ from git_cli.git_repo import CHUNK_BASE from git_cli import epic_branch from failure import Failure from forge.commands import Forge, forge_of, gitea, Run, runner +from atlassian.jira import ISSUE_KEY from project_config.main import located from project_config.settings import ProjectConfig from plan_store.plans import says_no_item @@ -385,6 +386,8 @@ def review_asked(forge: Forge, number: str, run: Run, config: Config) -> str | N def epic_opened(epic: str, title: str, body: str, run: Run, config: Config) -> str | Failure: """Bring the working branch of the epic with the key epic level with origin's default branch, then open its pull request into that branch, ready, for a person to merge.""" + if not ISSUE_KEY.fullmatch(epic): + return Failure(f"{epic!r} is no epic's key, such as ABC-123") loaded = config() if isinstance(loaded, Failure): return loaded diff --git a/bin/chunk_pr/test_chunk_pr.py b/bin/chunk_pr/test_chunk_pr.py index e2583fc2..7dc5fb1a 100644 --- a/bin/chunk_pr/test_chunk_pr.py +++ b/bin/chunk_pr/test_chunk_pr.py @@ -1150,6 +1150,8 @@ class EpicBranch(unittest.TestCase): checkout = self.epic() self.assertEqual(step(["open-epic", "ABC-1", "Ship\nit"], checkout, checkout.config), Failure("give a title of one line")) self.assertEqual(step(["open-epic", "ABC-1"], checkout, checkout.config), Failure(USAGE)) + self.assertEqual(step(["open-epic", "abc/../1", "Ship it"], checkout, checkout.config), Failure("'abc/../1' is no epic's key, such as ABC-123")) + self.assertEqual(checkout.ran, []) self.assertEqual(checkout.ran, []) diff --git a/bin/project_config/settings.py b/bin/project_config/settings.py index 347a1baa..c847c644 100644 --- a/bin/project_config/settings.py +++ b/bin/project_config/settings.py @@ -368,8 +368,8 @@ def language_fault(value: object) -> str | None: def comment_fault(value: object) -> str | None: - """Why value is no comment to post on a pull request; None where it is one.""" - return None if isinstance(value, str) and value.strip() and "\n" not in value else 'not one line of text, such as "@coderabbitai review"' + """Why value is no comment to post on a pull request; None where it is one. A forge's CLI would read one that starts with `-` as an option.""" + return None if isinstance(value, str) and value.strip() and "\n" not in value and not value.startswith("-") else 'not one line of text that doesn\'t start with `-`, such as "@coderabbitai review"' # Each one-value setting, in the order `project-config` lists them. diff --git a/bin/project_config/test_project_config.py b/bin/project_config/test_project_config.py index 4e1d46b1..5860c3e9 100644 --- a/bin/project_config/test_project_config.py +++ b/bin/project_config/test_project_config.py @@ -288,6 +288,8 @@ class LoadTest(ConfigCase): self.assertIn("`review-request-comment` is set, so `epic-branch` must be set", self.failure()) (self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = " "\n') self.assertIn("`review-request-comment` is ' ', not one line of text", self.failure()) + (self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = "--help"\n') + self.assertIn("`review-request-comment` is '--help', not one line of text that doesn't start with `-`", self.failure()) def test_a_jira_plan_may_name_the_transition_and_status_that_finish_an_item(self) -> None: self.write("acme", JIRA_CLIENT)