(repo, { ref, sha }, errors, warnings, token)
| 237 | } |
| 238 | |
| 239 | async function validateRemoteRepository(repo, { ref, sha }, errors, warnings, token) { |
| 240 | const encodedRepo = encodeRepoPath(repo); |
| 241 | const repositoryResponse = await fetchGitHubJson(`/repos/${encodedRepo}`, token); |
| 242 | |
| 243 | if (repositoryResponse.kind === "notFound") { |
| 244 | errors.push(`submission: GitHub repository "${repo}" was not found`); |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | if (repositoryResponse.kind === "apiError") { |
| 249 | const statusText = repositoryResponse.status ? `HTTP ${repositoryResponse.status}` : "network error"; |
| 250 | warnings.push( |
| 251 | `submission: could not verify GitHub repository "${repo}" (${statusText}${repositoryResponse.reason ? ` — ${repositoryResponse.reason}` : ""}); a maintainer should re-run intake`, |
| 252 | ); |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | if (repositoryResponse.data?.private) { |
| 257 | errors.push(`submission: GitHub repository "${repo}" must be public`); |
| 258 | } |
| 259 | |
| 260 | if (repositoryResponse.data?.archived) { |
| 261 | warnings.push(`submission: GitHub repository "${repo}" is archived`); |
| 262 | } |
| 263 | |
| 264 | if (sha) { |
| 265 | if (/^[0-9a-f]{40}$/i.test(sha)) { |
| 266 | const commitResponse = await fetchGitHubJson(`/repos/${encodedRepo}/git/commits/${encodeURIComponent(sha)}`, token); |
| 267 | if (commitResponse.kind === "notFound") { |
| 268 | errors.push(`submission: commit "${sha}" was not found in GitHub repository "${repo}"`); |
| 269 | } else if (commitResponse.kind === "apiError") { |
| 270 | const statusText = commitResponse.status ? `HTTP ${commitResponse.status}` : "network error"; |
| 271 | warnings.push( |
| 272 | `submission: could not verify commit "${sha}" in GitHub repository "${repo}" (${statusText}${commitResponse.reason ? ` — ${commitResponse.reason}` : ""}); a maintainer should re-run intake`, |
| 273 | ); |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | if (!ref) { |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | if (/^[0-9a-f]{40}$/i.test(ref)) { |
| 283 | const commitResponse = await fetchGitHubJson(`/repos/${encodedRepo}/git/commits/${encodeURIComponent(ref)}`, token); |
| 284 | if (commitResponse.kind === "notFound") { |
| 285 | errors.push(`submission: commit "${ref}" was not found in GitHub repository "${repo}"`); |
| 286 | } else if (commitResponse.kind === "apiError") { |
| 287 | const statusText = commitResponse.status ? `HTTP ${commitResponse.status}` : "network error"; |
| 288 | warnings.push( |
| 289 | `submission: could not verify commit "${ref}" in GitHub repository "${repo}" (${statusText}${commitResponse.reason ? ` — ${commitResponse.reason}` : ""}); a maintainer should re-run intake`, |
| 290 | ); |
| 291 | } |
| 292 | return; |
| 293 | } |
| 294 | |
| 295 | if (ref.startsWith("refs/heads/") || ["main", "master", "develop", "development", "dev", "trunk"].includes(ref)) { |
| 296 | return; |
no test coverage detected