Adds structured issue-branch ownership parsing, wires it into lock adoption and gitea_lock_issue validation, documents the restart recovery workflow, and adds regression tests for adoption, durable create_pr resolution, and open-PR blocking without remote branch deletion. Built on keyed persistent lock store and own-branch adoption (#443 / #442). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""Structured issue branch ownership (#440)."""
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
|
|
import issue_branch_ownership as ibo # noqa: E402
|
|
|
|
|
|
class TestIssueBranchOwnership(unittest.TestCase):
|
|
def test_canonical_branch_parses_issue_number(self):
|
|
self.assertEqual(
|
|
ibo.parse_issue_branch("feat/issue-420-server-code-parity"),
|
|
420,
|
|
)
|
|
|
|
def test_prefix_variants_supported(self):
|
|
for prefix in ("fix", "feat", "docs", "chore"):
|
|
branch = f"{prefix}/issue-440-lock-recovery"
|
|
self.assertTrue(ibo.branch_belongs_to_issue(branch, 440))
|
|
|
|
def test_substring_false_positive_rejected(self):
|
|
self.assertFalse(
|
|
ibo.branch_belongs_to_issue("feat/my-issue-420-backport", 420)
|
|
)
|
|
self.assertFalse(ibo.branch_belongs_to_issue("release/issue-420-hotfix", 420))
|
|
|
|
def test_different_issue_number_rejected(self):
|
|
self.assertFalse(
|
|
ibo.branch_belongs_to_issue("feat/issue-421-server-code-parity", 420)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main() |