Skip to content

Commit b3c164c

Browse files
Merge branch 'main' into ghes-review-agent
2 parents ad56a07 + e20d514 commit b3c164c

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111
- Fixed spurious infinite loads with explore panel, file tree, and file search command. [#617](https://github.com/sourcebot-dev/sourcebot/pull/617)
1212
- Wipe search context on init if entitlement no longer exists [#618](https://github.com/sourcebot-dev/sourcebot/pull/618)
13+
- Fixed Bitbucket repository exclusions not supporting glob patterns. [#620](https://github.com/sourcebot-dev/sourcebot/pull/620)
1314
- Fixed review agent so that it works with GHES instances [#611](https://github.com/sourcebot-dev/sourcebot/pull/611)
1415

1516
## [4.9.2] - 2025-11-13

packages/backend/src/bitbucket.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ClientOptions, ClientPathsWithMethod } from "openapi-fetch";
55
import { createLogger } from "@sourcebot/shared";
66
import { measure, fetchWithRetry } from "./utils.js";
77
import * as Sentry from "@sentry/node";
8+
import micromatch from "micromatch";
89
import {
910
SchemaRepository as CloudRepository,
1011
} from "@coderabbitai/bitbucket/cloud/openapi";
@@ -346,23 +347,31 @@ async function cloudGetRepos(client: BitbucketClient, repoList: string[]): Promi
346347

347348
function cloudShouldExcludeRepo(repo: BitbucketRepository, config: BitbucketConnectionConfig): boolean {
348349
const cloudRepo = repo as CloudRepository;
350+
let reason = '';
351+
const repoName = cloudRepo.full_name!;
349352

350353
const shouldExclude = (() => {
351-
if (config.exclude?.repos && config.exclude.repos.includes(cloudRepo.full_name!)) {
352-
return true;
354+
if (config.exclude?.repos) {
355+
if (micromatch.isMatch(repoName, config.exclude.repos)) {
356+
reason = `\`exclude.repos\` contains ${repoName}`;
357+
return true;
358+
}
353359
}
354360

355361
if (!!config.exclude?.archived) {
356362
logger.warn(`Exclude archived repos flag provided in config but Bitbucket Cloud does not support archived repos. Ignoring...`);
357363
}
358364

359365
if (!!config.exclude?.forks && cloudRepo.parent !== undefined) {
366+
reason = `\`exclude.forks\` is true`;
360367
return true;
361368
}
369+
370+
return false;
362371
})();
363372

364373
if (shouldExclude) {
365-
logger.debug(`Excluding repo ${cloudRepo.full_name} because it matches the exclude pattern`);
374+
logger.debug(`Excluding repo ${repoName}. Reason: ${reason}`);
366375
return true;
367376
}
368377
return false;
@@ -548,23 +557,32 @@ function serverShouldExcludeRepo(repo: BitbucketRepository, config: BitbucketCon
548557

549558
const projectName = serverRepo.project!.key;
550559
const repoSlug = serverRepo.slug!;
560+
const repoName = `${projectName}/${repoSlug}`;
561+
let reason = '';
551562

552563
const shouldExclude = (() => {
553-
if (config.exclude?.repos && config.exclude.repos.includes(`${projectName}/${repoSlug}`)) {
554-
return true;
564+
if (config.exclude?.repos) {
565+
if (micromatch.isMatch(repoName, config.exclude.repos)) {
566+
reason = `\`exclude.repos\` contains ${repoName}`;
567+
return true;
568+
}
555569
}
556570

557571
if (!!config.exclude?.archived && serverRepo.archived) {
572+
reason = `\`exclude.archived\` is true`;
558573
return true;
559574
}
560575

561576
if (!!config.exclude?.forks && serverRepo.origin !== undefined) {
577+
reason = `\`exclude.forks\` is true`;
562578
return true;
563579
}
580+
581+
return false;
564582
})();
565583

566584
if (shouldExclude) {
567-
logger.debug(`Excluding repo ${projectName}/${repoSlug} because it matches the exclude pattern`);
585+
logger.debug(`Excluding repo ${repoName}. Reason: ${reason}`);
568586
return true;
569587
}
570588
return false;

0 commit comments

Comments
 (0)