fix: inject duplicate-work context fetcher for testable lock/create_pr paths (#400)
Expose issue_duplicate_context_fetcher on the MCP server so lock_issue, commit_files, and create_pr duplicate rechecks avoid live Gitea calls in unit tests. Update affected test suites to patch the fetcher without weakening duplicate-work gate assertions. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
+18
-2
@@ -548,7 +548,7 @@ def _load_existing_issue_lock() -> dict | None:
|
||||
if not os.path.exists(ISSUE_LOCK_FILE):
|
||||
return None
|
||||
try:
|
||||
with open(ISSUE_LOCK_FILE, encoding="utf-8") as f:
|
||||
with open(ISSUE_LOCK_FILE, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
return data if isinstance(data, dict) else None
|
||||
except Exception:
|
||||
@@ -642,7 +642,7 @@ def _branch_entry_name(branch: dict | str) -> str:
|
||||
return str(branch.get("name") or branch.get("ref") or "")
|
||||
|
||||
|
||||
def _collect_issue_duplicate_context(
|
||||
def _live_fetch_issue_duplicate_context(
|
||||
h: str,
|
||||
o: str,
|
||||
r: str,
|
||||
@@ -667,6 +667,22 @@ def _collect_issue_duplicate_context(
|
||||
return open_prs, branch_names, claim_entry
|
||||
|
||||
|
||||
# Injectable duplicate-work context fetcher (#400). Production uses the live
|
||||
# Gitea API path above; unit tests patch this symbol instead of hitting the
|
||||
# network.
|
||||
issue_duplicate_context_fetcher = _live_fetch_issue_duplicate_context
|
||||
|
||||
|
||||
def _collect_issue_duplicate_context(
|
||||
h: str,
|
||||
o: str,
|
||||
r: str,
|
||||
auth: str,
|
||||
issue_number: int,
|
||||
) -> tuple[list[dict], list[str], dict]:
|
||||
return issue_duplicate_context_fetcher(h, o, r, auth, issue_number)
|
||||
|
||||
|
||||
def _assess_issue_duplicate_gate(
|
||||
issue_number: int,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user