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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Fixed GitLab connection topic filters (`topics` / `exclude.topics`) being case-sensitive on the project side, so mixed-case GitLab project topics (e.g. `Backend`) now match lowercase config topics. [#1388](https://github.com/sourcebot-dev/sourcebot/issues/1388)

## [5.1.0] - 2026-07-10

### Changed
Expand Down
19 changes: 16 additions & 3 deletions packages/backend/src/gitlab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,29 @@ 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 include.topics matching is case-insensitive on the project side.', () => {
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'.
// Both config and project topics are lowercased before matching,
// so the mixed-case project topic 'Backend' matches the pattern 'backend'.
expect(shouldExcludeProject({
project,
include: { topics: ['backend'] },
})).toBe(false);
});

test('shouldExcludeProject exclude.topics matching is case-insensitive on the project side.', () => {
const project = {
path_with_namespace: 'test/project',
topics: ['Deprecated'],
} as unknown as ProjectSchema;

// The mixed-case project topic 'Deprecated' matches the exclude pattern 'deprecated'.
expect(shouldExcludeProject({
project,
exclude: { topics: ['deprecated'] },
})).toBe(true);
});
4 changes: 2 additions & 2 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