-
Notifications
You must be signed in to change notification settings - Fork 1
fix: enforce spec compliance in GitHub module #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -162,10 +162,19 @@ export function listDiscussions( | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const hasCategory = categoryId !== undefined; | ||||||||||||||||||||||||||||
| const query = ` | ||||||||||||||||||||||||||||
| query($owner: String!, $repo: String!, $first: Int!${hasCategory ? ', $categoryId: ID!' : ''}) { | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const allNodes: RawDiscussion[] = []; | ||||||||||||||||||||||||||||
| let hasNextPage = true; | ||||||||||||||||||||||||||||
| let endCursor: string | null = null; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| while (hasNextPage) { | ||||||||||||||||||||||||||||
| const afterClause = endCursor ? `, after: $after` : ''; | ||||||||||||||||||||||||||||
| const afterVar = endCursor ? ', $after: String!' : ''; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const query = ` | ||||||||||||||||||||||||||||
| query($owner: String!, $repo: String!, $first: Int!${hasCategory ? ', $categoryId: ID!' : ''}${afterVar}) { | ||||||||||||||||||||||||||||
| repository(owner: $owner, name: $repo) { | ||||||||||||||||||||||||||||
| discussions(first: $first${hasCategory ? ', categoryId: $categoryId' : ''}) { | ||||||||||||||||||||||||||||
| discussions(first: $first${hasCategory ? ', categoryId: $categoryId' : ''}${afterClause}) { | ||||||||||||||||||||||||||||
| nodes { | ||||||||||||||||||||||||||||
| number | ||||||||||||||||||||||||||||
| id | ||||||||||||||||||||||||||||
|
|
@@ -176,31 +185,54 @@ export function listDiscussions( | |||||||||||||||||||||||||||
| createdAt | ||||||||||||||||||||||||||||
| updatedAt | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| pageInfo { | ||||||||||||||||||||||||||||
| hasNextPage | ||||||||||||||||||||||||||||
| endCursor | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| `.trim(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const args = [ | ||||||||||||||||||||||||||||
| 'api', 'graphql', | ||||||||||||||||||||||||||||
| '-f', `query=${query}`, | ||||||||||||||||||||||||||||
| '-f', `owner=${owner}`, | ||||||||||||||||||||||||||||
| '-f', `repo=${repoName}`, | ||||||||||||||||||||||||||||
| '-F', `first=${first}`, | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
| const args = [ | ||||||||||||||||||||||||||||
| 'api', 'graphql', | ||||||||||||||||||||||||||||
| '-f', `query=${query}`, | ||||||||||||||||||||||||||||
| '-f', `owner=${owner}`, | ||||||||||||||||||||||||||||
| '-f', `repo=${repoName}`, | ||||||||||||||||||||||||||||
| '-F', `first=${first}`, | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (hasCategory) { | ||||||||||||||||||||||||||||
| args.push('-f', `categoryId=${categoryId}`); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| if (hasCategory) { | ||||||||||||||||||||||||||||
| args.push('-f', `categoryId=${categoryId}`); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const result = ghJson<{ | ||||||||||||||||||||||||||||
| data: { repository: { discussions: { nodes: RawDiscussion[] } } }; | ||||||||||||||||||||||||||||
| }>(args); | ||||||||||||||||||||||||||||
| if (endCursor) { | ||||||||||||||||||||||||||||
| args.push('-f', `after=${endCursor}`); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (!result.ok) return result; | ||||||||||||||||||||||||||||
| const result = ghJson<{ | ||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||
| repository: { | ||||||||||||||||||||||||||||
| discussions: { | ||||||||||||||||||||||||||||
| nodes: RawDiscussion[]; | ||||||||||||||||||||||||||||
| pageInfo: { hasNextPage: boolean; endCursor: string | null }; | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| }>(args); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (!result.ok) return result; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const discussions = result.data?.data?.repository?.discussions; | ||||||||||||||||||||||||||||
| const nodes = discussions?.nodes ?? []; | ||||||||||||||||||||||||||||
| allNodes.push(...nodes); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const pageInfo = discussions?.pageInfo; | ||||||||||||||||||||||||||||
| hasNextPage = pageInfo?.hasNextPage ?? false; | ||||||||||||||||||||||||||||
| endCursor = pageInfo?.endCursor ?? null; | ||||||||||||||||||||||||||||
|
Comment on lines
+231
to
+232
|
||||||||||||||||||||||||||||
| hasNextPage = pageInfo?.hasNextPage ?? false; | |
| endCursor = pageInfo?.endCursor ?? null; | |
| const nextHasNextPage = pageInfo?.hasNextPage ?? false; | |
| const nextEndCursor = pageInfo?.endCursor ?? null; | |
| // Guard against a potential infinite loop if GitHub reports hasNextPage | |
| // but does not provide an endCursor for the next page. | |
| if (nextHasNextPage && !nextEndCursor) { | |
| break; | |
| } | |
| hasNextPage = nextHasNextPage; | |
| endCursor = nextEndCursor; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -257,10 +257,11 @@ export async function ensureProjectBoard( | |||||
| ]); | ||||||
|
|
||||||
| if (!updateResult.ok) { | ||||||
| console.warn( | ||||||
| `Warning: Failed to add missing Status options (${missingColumns.map((c) => c.name).join(', ')}): ${updateResult.error}. ` + | ||||||
| 'You may need to add them manually via the GitHub Projects UI.', | ||||||
| ); | ||||||
| return { | ||||||
| ok: false, | ||||||
| error: `Failed to add missing Status options (${missingColumns.map((c) => c.name).join(', ')}): ${updateResult.error}`, | ||||||
| code: 'UNKNOWN', | ||||||
|
||||||
| code: 'UNKNOWN', | |
| code: updateResult.code ?? 'UNKNOWN', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VALID_COMMENT_TYPESduplicates theMaxsimCommentMeta['type']union intypes.ts, which can drift over time. Consider defining a single exportedconstarray of comment types and deriving both the union type and the runtime Set/type-guard from it to keep them in sync.