MCPcopy Create free account
hub / github.com/github/gh-aw / fetchAllRepoLabels

Function fetchAllRepoLabels

actions/setup/js/github_api_helpers.cjs:110–142  ·  view source on GitHub ↗

* Fetches all labels from a repository, paginating through all pages. * @param {any} githubClient - GitHub API client * @param {string} owner - Repository owner * @param {string} repo - Repository name * @returns {Promise >} All repository labels

(githubClient, owner, repo)

Source from the content-addressed store, hash-verified

108 * @returns {Promise<Array<{id: string, name: string}>>} All repository labels
109 */
110async function fetchAllRepoLabels(githubClient, owner, repo) {
111 const labelsQuery = `
112 query($owner: String!, $repo: String!, $cursor: String) {
113 repository(owner: $owner, name: $repo) {
114 labels(first: 100, after: $cursor) {
115 nodes {
116 id
117 name
118 }
119 pageInfo {
120 hasNextPage
121 endCursor
122 }
123 }
124 }
125 }
126 `;
127
128 const allLabels = /** @type {Array<{id: string, name: string}>} */ [];
129 let cursor = /** @type {string | null} */ null;
130 let hasNextPage = true;
131
132 while (hasNextPage) {
133 const queryResult = await githubClient.graphql(labelsQuery, { owner, repo, cursor });
134 const labelsPage = queryResult?.repository?.labels;
135 const nodes = labelsPage?.nodes || [];
136 allLabels.push(...nodes);
137 hasNextPage = labelsPage?.pageInfo?.hasNextPage ?? false;
138 cursor = labelsPage?.pageInfo?.endCursor ?? null;
139 }
140
141 return allLabels;
142}
143
144/**
145 * Resolves the top-level parent comment node ID for GitHub Discussion replies.

Callers 4

executeIssueUpdateFunction · 0.85
fetchLabelIdsFunction · 0.85
fetchLabelNodeIdsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected