({
repo,
include,
exclude
}: {
repo: OctokitRepository,
include?: {
topics?: GithubConnectionConfig['topics']
},
exclude?: GithubConnectionConfig['exclude']
})
| 477 | } |
| 478 | |
| 479 | export const shouldExcludeRepo = ({ |
| 480 | repo, |
| 481 | include, |
| 482 | exclude |
| 483 | }: { |
| 484 | repo: OctokitRepository, |
| 485 | include?: { |
| 486 | topics?: GithubConnectionConfig['topics'] |
| 487 | }, |
| 488 | exclude?: GithubConnectionConfig['exclude'] |
| 489 | }) => { |
| 490 | let reason = ''; |
| 491 | const repoName = repo.full_name; |
| 492 | |
| 493 | const shouldExclude = (() => { |
| 494 | if (!repo.clone_url) { |
| 495 | reason = 'clone_url is undefined'; |
| 496 | return true; |
| 497 | } |
| 498 | |
| 499 | if (!!exclude?.forks && repo.fork) { |
| 500 | reason = `\`exclude.forks\` is true`; |
| 501 | return true; |
| 502 | } |
| 503 | |
| 504 | if (!!exclude?.archived && !!repo.archived) { |
| 505 | reason = `\`exclude.archived\` is true`; |
| 506 | return true; |
| 507 | } |
| 508 | |
| 509 | if (exclude?.repos) { |
| 510 | if (micromatch.isMatch(repoName, exclude.repos)) { |
| 511 | reason = `\`exclude.repos\` contains ${repoName}`; |
| 512 | return true; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | if (exclude?.topics) { |
| 517 | const configTopics = exclude.topics.map(topic => topic.toLowerCase()); |
| 518 | const repoTopics = repo.topics ?? []; |
| 519 | |
| 520 | const matchingTopics = repoTopics.filter((topic) => micromatch.isMatch(topic, configTopics)); |
| 521 | if (matchingTopics.length > 0) { |
| 522 | reason = `\`exclude.topics\` matches the following topics: ${matchingTopics.join(', ')}`; |
| 523 | return true; |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | if (include?.topics) { |
| 528 | const configTopics = include.topics.map(topic => topic.toLowerCase()); |
| 529 | const repoTopics = repo.topics ?? []; |
| 530 | |
| 531 | const matchingTopics = repoTopics.filter((topic) => micromatch.isMatch(topic, configTopics)); |
| 532 | if (matchingTopics.length === 0) { |
| 533 | reason = `\`include.topics\` does not match any of the following topics: ${configTopics.join(', ')}`; |
| 534 | return true; |
| 535 | } |
| 536 | } |
no outgoing calls
no test coverage detected