fix: paginate repositories and parse all remote URL formats#176
fix: paginate repositories and parse all remote URL formats#176Harshi-Shah-CS wants to merge 1 commit into
Conversation
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
| const edges = repositories?.edges ?? []; | ||
| repositoriesRes.push(...map(edges, 'node')); | ||
|
|
||
| // Paginate while a full page is returned; the backend's hasNextPage is unreliable. |
There was a problem hiding this comment.
Why is the backend's hasNextPage is unreliable.?
| } | ||
|
|
||
| let repositories; | ||
| let repositories: any[] = []; |
There was a problem hiding this comment.
Can we have a defined type instead of any?
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub adapter’s repository discovery to support paginated repository fetching and to correctly parse additional GitHub remote URL formats (notably HTTPS remotes that include userinfo). This helps the CLI locate the current repo even when it’s not in the first page of repositories returned to the GitHub App.
Changes:
- Replace the repositories GraphQL query with a paginated
GitRepositoriesquery shape (edges/pageInfo) and add variables forfirst/page. - Add recursive repository pagination in the GitHub adapter (capped at
MAX_REPOSITORY_PAGES) and expand remote URL parsing to handle more HTTPS/SSH formats. - Extend adapter tests to cover userinfo URLs, multi-page lookup, and pagination capping; bump package version.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/graphql/queries.ts | Switch repositories query to a paginated GitRepositories query with first/page variables and edges response shape. |
| src/adapters/github.ts | Add pagination helper for repositories, update flow to select org earlier, and broaden GitHub remote URL parsing regexes. |
| src/adapters/github.test.ts | Update mocks for new query response shape and add tests for userinfo URL parsing + pagination behaviors. |
| package.json | Bump package version to 1.11.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let repositories: any[] = []; | ||
| try { | ||
| const repositoriesQueryResponse = await this.apolloClient.query({ query: repositoriesQuery }); | ||
| repositories = repositoriesQueryResponse.data.repositories; | ||
| repositories = await this.queryRepositories({ page: 1, first: 100 }); | ||
| } catch { |
| async queryRepositories(variables: Record<string, any>, repositoriesRes: any[] = []): Promise<any[]> { | ||
| const { data: { repositories } } = await this.apolloClient.query({ | ||
| query: repositoriesQuery, | ||
| variables, | ||
| }); | ||
|
|
||
| const edges = repositories?.edges ?? []; | ||
| repositoriesRes.push(...map(edges, 'node')); | ||
|
|
||
| // Paginate while a full page is returned; the backend's hasNextPage is unreliable. | ||
| if (edges.length === variables.first) { | ||
| if ((variables.page ?? 1) >= MAX_REPOSITORY_PAGES) { | ||
| return repositoriesRes; | ||
| } | ||
| variables.page = (variables.page ?? 1) + 1; | ||
| return await this.queryRepositories(variables, repositoriesRes); | ||
| } | ||
|
|
||
| return repositoriesRes; | ||
| } |
No description provided.