| 368 | } |
| 369 | |
| 370 | export function cloudShouldExcludeRepo(repo: BitbucketRepository, config: BitbucketConnectionConfig): boolean { |
| 371 | const cloudRepo = repo as CloudRepository; |
| 372 | let reason = ''; |
| 373 | const [workspace, repoSlug] = cloudRepo.full_name!.split('/'); |
| 374 | const repoName = `${workspace}/${cloudRepo.project?.key}/${repoSlug}`; |
| 375 | |
| 376 | const shouldExclude = (() => { |
| 377 | if (config.exclude?.repos) { |
| 378 | if (micromatch.isMatch(repoName, config.exclude.repos)) { |
| 379 | reason = `\`exclude.repos\` contains ${repoName}`; |
| 380 | return true; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | if (!!config.exclude?.archived) { |
| 385 | logger.warn(`Exclude archived repos flag provided in config but Bitbucket Cloud does not support archived repos. Ignoring...`); |
| 386 | } |
| 387 | |
| 388 | if (!!config.exclude?.forks && cloudRepo.parent !== undefined) { |
| 389 | reason = `\`exclude.forks\` is true`; |
| 390 | return true; |
| 391 | } |
| 392 | |
| 393 | return false; |
| 394 | })(); |
| 395 | |
| 396 | if (shouldExclude) { |
| 397 | logger.debug(`Excluding repo ${repoName}. Reason: ${reason}`); |
| 398 | return true; |
| 399 | } |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | export function createBitbucketServerClient(url: string, user: string | undefined, token: string | undefined): BitbucketClient { |
| 404 | const authorizationString = (() => { |