Add function to fetch PR contributed repositories - #414
Open
RajShree1854 wants to merge 1 commit into
Open
Conversation
RajShree1854
commented
Aug 23, 2026
- Add fetch_pr_contributed_repos to discover repositories with merged external PRs
- Integrate external PR detection into fetch_all_github_repos
- Fix filtering of open-source projects when direct author commits are 0, including squashed PR contributions
- Force-pin top 3 open-source repositories to LLM context for accurate contribution scoring
- Add fetch_pr_contributed_repos to discover repositories with merged external PRs - Integrate external PR detection into fetch_all_github_repos - Fix filtering of open-source projects when direct author commits are 0, including squashed PR contributions - Force-pin top 3 open-source repositories to LLM context for accurate contribution scoring
There was a problem hiding this comment.
Pull request overview
This pull request enhances GitHub repository discovery and selection by incorporating repositories where a user contributed via merged pull requests (including cases where commit attribution is missing due to squash/merge behavior), and by ensuring open-source projects are surfaced in the final LLM-facing project list.
Changes:
- Added
fetch_pr_contributed_repos()to discover external repositories where the user has merged PRs and include them in the repository set. - Integrated PR-contributed repositories into
fetch_all_github_repos()and adjusted filtering so open-source projects aren’t dropped whenauthor_commit_count == 0. - Updated project selection output to always pin the top 3 open-source repositories (by stars) into the final set returned for LLM context/output.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+358
to
+361
| owned_names = {p["name"] for p in projects} | ||
| for contrib in fetch_pr_contributed_repos(username): | ||
| if contrib.get("name") not in owned_names: | ||
| projects.append(contrib) |
Comment on lines
+219
to
+240
| github_token = os.environ.get("GITHUB_TOKEN") | ||
| headers = {} | ||
| if github_token: | ||
| headers["Authorization"] = f"token {github_token}" | ||
|
|
||
| try: | ||
| resp = requests.get( | ||
| "https://api.github.com/search/issues", | ||
| params={"q": f"author:{username} type:pr is:merged", "per_page": 100}, | ||
| headers=headers, | ||
| timeout=15, | ||
| ) | ||
| except Exception as e: | ||
| logger.error(f"PR search API failed for {username}: {e}") | ||
| return [] | ||
|
|
||
| if resp.status_code != 200: | ||
| logger.warning(f"PR search API returned {resp.status_code} for {username}") | ||
| return [] | ||
|
|
||
| external_repos: Dict[str, None] = {} | ||
| for item in resp.json().get("items", []): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.