diff --git a/CHANGELOG.md b/CHANGELOG.md index e6a630e4f..fe338382c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Upgraded `brace-expansion` to `^1.1.17`/`^2.1.3`/`^5.0.8`. [#1527](https://github.com/sourcebot-dev/sourcebot/pull/1527) - Upgraded `tar` to `^7.5.22`. [#1472](https://github.com/sourcebot-dev/sourcebot/pull/1472) +- Fixed GitLab connection topic filters being case-sensitive on the project side. [#1388](https://github.com/sourcebot-dev/sourcebot/issues/1388) ## [5.1.5] - 2026-07-31 diff --git a/packages/backend/src/gitlab.test.ts b/packages/backend/src/gitlab.test.ts index a502488df..956374a87 100644 --- a/packages/backend/src/gitlab.test.ts +++ b/packages/backend/src/gitlab.test.ts @@ -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); }); diff --git a/packages/backend/src/gitlab.ts b/packages/backend/src/gitlab.ts index 94a6e0710..6cdadb43a 100644 --- a/packages/backend/src/gitlab.ts +++ b/packages/backend/src/gitlab.ts @@ -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) { @@ -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) {