Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Upgraded `nodemailer` to `^9.0.1`. [#1356](https://github.com/sourcebot-dev/sourcebot/pull/1356)
- Upgraded `@opentelemetry/core` to `^2.8.0`. [#1413](https://github.com/sourcebot-dev/sourcebot/pull/1413)
- [EE] Fixed connector setup dialogs to add scrolling when connector setup content goes out of view.
- Fixed GitLab topic include and exclude filters missing mixed-case project topics. [#1393](https://github.com/sourcebot-dev/sourcebot/pull/1393)

## [5.0.4] - 2026-06-18

Expand Down
28 changes: 25 additions & 3 deletions packages/backend/src/gitlab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ test('shouldExcludeProject returns false when include.topics matches via glob pa
})).toBe(false);
});

test('shouldExcludeProject matches include.topics glob patterns case-insensitively.', () => {
const project = {
path_with_namespace: 'test/project',
topics: ['Core-API'],
} as unknown as ProjectSchema;

expect(shouldExcludeProject({
project,
include: { topics: ['core-*'] },
})).toBe(false);
});

test('shouldExcludeProject returns true when exclude.topics matches a project topic.', () => {
const project = {
path_with_namespace: 'test/project',
Expand All @@ -141,16 +153,26 @@ test('shouldExcludeProject returns false when exclude.topics does not match any
})).toBe(false);
});

test('shouldExcludeProject include.topics matching is case-sensitive on the project side.', () => {
test('shouldExcludeProject matches include.topics case-insensitively.', () => {
const project = {
path_with_namespace: 'test/project',
topics: ['Backend'],
} as unknown as ProjectSchema;

// The function lowercases config topics but not project topics,
// so 'Backend' does not match the lowercased pattern 'backend'.
expect(shouldExcludeProject({
project,
include: { topics: ['backend'] },
})).toBe(false);
});

test('shouldExcludeProject matches exclude.topics case-insensitively.', () => {
const project = {
path_with_namespace: 'test/project',
topics: ['Deprecated'],
} as unknown as ProjectSchema;

expect(shouldExcludeProject({
project,
exclude: { topics: ['deprecated'] },
})).toBe(true);
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
6 changes: 3 additions & 3 deletions packages/backend/src/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export const shouldExcludeProject = ({

if (include?.topics) {
const configTopics = include.topics.map(topic => topic.toLowerCase());
const projectTopics = project.topics ?? [];
const projectTopics = (project.topics ?? []).map(topic => topic.toLowerCase());

const matchingTopics = projectTopics.filter((topic) => micromatch.isMatch(topic, configTopics));
if (matchingTopics.length === 0) {
Expand All @@ -260,7 +260,7 @@ export const shouldExcludeProject = ({

if (exclude?.topics) {
const configTopics = exclude.topics.map(topic => topic.toLowerCase());
const projectTopics = project.topics ?? [];
const projectTopics = (project.topics ?? []).map(topic => topic.toLowerCase());

const matchingTopics = projectTopics.filter((topic) => micromatch.isMatch(topic, configTopics));
if (matchingTopics.length > 0) {
Expand Down Expand Up @@ -333,4 +333,4 @@ export const getOAuthScopesForAuthenticatedUser = async (api: InstanceType<typeo
logger.error('Failed to fetch OAuth scopes for authenticated user.', error);
throw error;
}
}
}