|
25 | 25 | LARGE_PR_FILE_THRESHOLD = 50 # Files to summarize above which tiered mode activates |
26 | 26 | LARGE_PR_SYNTHESIS_THRESHOLD = 40 # Per-file summaries above which two-stage synthesis activates |
27 | 27 | COMMENT_IDENTIFIER = "<!-- lean-pr-summary-{{timestamp}} -->" |
28 | | -LEGACY_COMMENT_IDENTIFIER = "<!-- gemini-pr-summary-{{timestamp}} -->" |
29 | 28 | CACHE_IDENTIFIER = "<!-- lean-summary-cache: " |
30 | | -LEGACY_CACHE_IDENTIFIER = "<!-- gemini-cache: " |
31 | 29 |
|
32 | 30 | # --- Global Provider and Token Tracker --- |
33 | 31 | _provider: LLMProvider = None # Initialized in main() |
@@ -622,19 +620,18 @@ def __init__(self, pr: PullRequest, config_fingerprint: str): |
622 | 620 | def _load_from_comment(self, pr: PullRequest): |
623 | 621 | comment = find_existing_comment(pr) |
624 | 622 | if comment: |
625 | | - for marker in (CACHE_IDENTIFIER, LEGACY_CACHE_IDENTIFIER): |
626 | | - if marker not in comment.body: |
627 | | - continue |
628 | | - try: |
629 | | - cache_str = comment.body.split(marker, 1)[1].split("-->", 1)[0] |
630 | | - data = json.loads(cache_str) |
631 | | - # Invalidate entire cache if config fingerprint changed |
632 | | - if data.get("_config") != self._config_fingerprint: |
633 | | - print("Cache invalidated: model or prompt template changed.") |
634 | | - return {} |
635 | | - return data |
636 | | - except (IndexError, json.JSONDecodeError): |
| 623 | + if CACHE_IDENTIFIER not in comment.body: |
| 624 | + return {} |
| 625 | + try: |
| 626 | + cache_str = comment.body.split(CACHE_IDENTIFIER, 1)[1].split("-->", 1)[0] |
| 627 | + data = json.loads(cache_str) |
| 628 | + # Invalidate entire cache if config fingerprint changed |
| 629 | + if data.get("_config") != self._config_fingerprint: |
| 630 | + print("Cache invalidated: model or prompt template changed.") |
637 | 631 | return {} |
| 632 | + return data |
| 633 | + except (IndexError, json.JSONDecodeError): |
| 634 | + return {} |
638 | 635 | return {} |
639 | 636 |
|
640 | 637 | def get(self, file_path, file_diff_hash): |
@@ -837,11 +834,7 @@ def get_github_objects(token, repo_name, pr_number): |
837 | 834 |
|
838 | 835 | def find_existing_comment(pr: PullRequest): |
839 | 836 | """Finds a comment previously posted by this action.""" |
840 | | - patterns = [ |
841 | | - COMMENT_IDENTIFIER.replace("{{timestamp}}", ".*?"), |
842 | | - LEGACY_COMMENT_IDENTIFIER.replace("{{timestamp}}", ".*?"), |
843 | | - ] |
844 | | - comment_regex = re.compile("|".join(f"(?:{p})" for p in patterns)) |
| 837 | + comment_regex = re.compile(COMMENT_IDENTIFIER.replace("{{timestamp}}", ".*?")) |
845 | 838 | return next((c for c in pr.get_issue_comments() if comment_regex.search(c.body)), None) |
846 | 839 |
|
847 | 840 | def post_github_comment(pr: PullRequest, summary: str): |
|
0 commit comments