({
repo,
exclude
}: {
repo: GitRepository,
exclude?: AzureDevOpsConnectionConfig['exclude']
})
| 96 | }; |
| 97 | |
| 98 | export const shouldExcludeRepo = ({ |
| 99 | repo, |
| 100 | exclude |
| 101 | }: { |
| 102 | repo: GitRepository, |
| 103 | exclude?: AzureDevOpsConnectionConfig['exclude'] |
| 104 | }) => { |
| 105 | let reason = ''; |
| 106 | const repoName = `${repo.project!.name}/${repo.name}`; |
| 107 | |
| 108 | const shouldExclude = (() => { |
| 109 | if (!repo.remoteUrl) { |
| 110 | reason = 'remoteUrl is undefined'; |
| 111 | return true; |
| 112 | } |
| 113 | |
| 114 | if (!!exclude?.disabled && repo.isDisabled) { |
| 115 | reason = `\`exclude.disabled\` is true`; |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | if (exclude?.repos) { |
| 120 | if (micromatch.isMatch(repoName, exclude.repos)) { |
| 121 | reason = `\`exclude.repos\` contains ${repoName}`; |
| 122 | return true; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | if (exclude?.projects) { |
| 127 | if (micromatch.isMatch(repo.project!.name!, exclude.projects)) { |
| 128 | reason = `\`exclude.projects\` contains ${repo.project!.name}`; |
| 129 | return true; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | const repoSizeInBytes = repo.size || 0; |
| 134 | if (exclude?.size && repoSizeInBytes) { |
| 135 | const min = exclude.size.min; |
| 136 | const max = exclude.size.max; |
| 137 | |
| 138 | if (min && repoSizeInBytes < min) { |
| 139 | reason = `repo is less than \`exclude.size.min\`=${min} bytes.`; |
| 140 | return true; |
| 141 | } |
| 142 | |
| 143 | if (max && repoSizeInBytes > max) { |
| 144 | reason = `repo is greater than \`exclude.size.max\`=${max} bytes.`; |
| 145 | return true; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | return false; |
| 150 | })(); |
| 151 | |
| 152 | if (shouldExclude) { |
| 153 | logger.debug(`Excluding repo ${repoName}. Reason: ${reason}`); |
| 154 | return true; |
| 155 | } |
no outgoing calls
no test coverage detected