|
8 | 8 | from agent_context_builder.config import Config |
9 | 9 | from agent_context_builder.discussions import Discussion, DiscussionCollector |
10 | 10 | from agent_context_builder.git_local import GitLocalCollector, GitState |
11 | | -from agent_context_builder.github import GitHubCollector |
| 11 | +from agent_context_builder.github import GitHubCollector, PR |
12 | 12 | from agent_context_builder.render import Renderer |
13 | 13 |
|
14 | 14 | _UNAVAILABLE = GitState(available=False, reason="path_not_found", dirty=None, current_branch=None) |
@@ -36,6 +36,21 @@ def _make_github_mock(prs=None, issues=None, fetch_errors=None, raw_file=None): |
36 | 36 | m.get_issues.return_value = issues or [] |
37 | 37 | m.fetch_errors = fetch_errors or {} |
38 | 38 | m.get_raw_file.return_value = raw_file # None by default = signal fetch fails gracefully |
| 39 | + errors = fetch_errors or {} |
| 40 | + if errors: |
| 41 | + msgs = " ".join(errors.values()).lower() |
| 42 | + if "403" in msgs or "rate limit" in msgs: |
| 43 | + m.collector_warning.return_value = ( |
| 44 | + "GitHub rate-limit or auth error " |
| 45 | + f"({len(errors)} collector(s) affected) - data may be incomplete" |
| 46 | + ) |
| 47 | + else: |
| 48 | + m.collector_warning.return_value = ( |
| 49 | + f"GitHub fetch error ({len(errors)} collector(s) affected) " |
| 50 | + "- data may be incomplete" |
| 51 | + ) |
| 52 | + else: |
| 53 | + m.collector_warning.return_value = None |
39 | 54 | return m |
40 | 55 |
|
41 | 56 |
|
@@ -77,10 +92,34 @@ def test_render_session_bootstrap_github_error(): |
77 | 92 | ) |
78 | 93 | bootstrap = renderer.render_session_bootstrap() |
79 | 94 |
|
80 | | - assert "GitHub unavailable" in bootstrap |
| 95 | + assert "rate-limit" in bootstrap |
81 | 96 | assert "No open PRs" not in bootstrap |
82 | 97 |
|
83 | 98 |
|
| 99 | +def test_render_session_bootstrap_groups_dependabot_prs(): |
| 100 | + """Bootstrap keeps Dependabot PRs compact and leaves feature PRs visible.""" |
| 101 | + config = Config( |
| 102 | + workspace_root=Path("/tmp/test"), |
| 103 | + github_org="test-org", |
| 104 | + repos=["repo1"], |
| 105 | + ) |
| 106 | + prs = [ |
| 107 | + PR(1, "feat: improve context", "repo1", "https://example.test/pr/1", author="gabry"), |
| 108 | + PR(2, "chore(deps): bump package", "repo1", "https://example.test/pr/2", author="dependabot[bot]"), |
| 109 | + PR(3, "chore(deps): bump action", "repo1", "https://example.test/pr/3", author="dependabot[bot]"), |
| 110 | + ] |
| 111 | + renderer = Renderer( |
| 112 | + config, |
| 113 | + _make_github_mock(prs=prs), |
| 114 | + _make_git_mock({"repo1": _UNAVAILABLE}), |
| 115 | + ) |
| 116 | + bootstrap = renderer.render_session_bootstrap() |
| 117 | + |
| 118 | + assert "feat: improve context" in bootstrap |
| 119 | + assert "**Dependabot**: 2 bump PR(s)" in bootstrap |
| 120 | + assert "chore(deps): bump package" not in bootstrap |
| 121 | + |
| 122 | + |
84 | 123 | def test_render_workspace_triage(): |
85 | 124 | """Test workspace_triage.json rendering with no errors.""" |
86 | 125 | config = Config( |
|
0 commit comments