From 7020761ca691b74d05cb13e40922bb8d77f113bb Mon Sep 17 00:00:00 2001 From: Tarang Chikhalia Date: Thu, 18 Sep 2025 18:06:46 -0400 Subject: [PATCH] fix(backend): Sourcebot not pulling github forked repos (#499) --- CHANGELOG.md | 3 +++ packages/backend/src/github.ts | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f621c8e1..6ff22a8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed sourcebot not pulling github forked repos [#499](https://github.com/sourcebot-dev/sourcebot/pull/499) + ## [4.7.0] - 2025-09-17 ### Added diff --git a/packages/backend/src/github.ts b/packages/backend/src/github.ts index 7c53bf37..34f01724 100644 --- a/packages/backend/src/github.ts +++ b/packages/backend/src/github.ts @@ -225,13 +225,17 @@ const getReposOwnedByUsers = async (users: string[], octokit: Octokit, signal: A const { durationMs, data } = await measure(async () => { const fetchFn = async () => { + let query = `user:${user}`; + // To include forks in the search results, we will need to add fork:true + // see: https://docs.github.com/en/search-github/searching-on-github/searching-for-repositories + query += ' fork:true'; // @note: We need to use GitHub's search API here since it is the only way // to get all repositories (private and public) owned by a user that supports // the username as a parameter. // @see: https://github.com/orgs/community/discussions/24382#discussioncomment-3243958 // @see: https://api.github.com/search/repositories?q=user:USERNAME const searchResults = await octokit.paginate(octokit.rest.search.repos, { - q: `user:${user}`, + q: query, per_page: 100, request: { signal,