Skip to content

Commit 2d7486e

Browse files
committed
Merge branch 'main' into feature/gerrit-authentication
Resolved conflicts: - CHANGELOG.md: Merged Gerrit auth entry with new 4.6.7 release section
2 parents b9cc506 + ccd0706 commit 2d7486e

File tree

15 files changed

+90
-4
lines changed

15 files changed

+90
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- Added comprehensive Gerrit HTTP authentication support with username/password credentials via secrets and environment variables. [#366](https://github.com/sourcebot-dev/sourcebot/pull/366)
1212

13+
## [4.6.7] - 2025-09-08
14+
15+
### Added
16+
- Added `exclude.userOwnedProjects` setting to GitLab configs. [#498](https://github.com/sourcebot-dev/sourcebot/pull/498)
17+
18+
### Fixed
19+
- Fixed "couldn't find remote ref HEAD" errors when re-indexing certain repositories. [#497](https://github.com/sourcebot-dev/sourcebot/pull/497)
20+
1321
### Changed
1422
- Disable page scroll when using arrow keys on search suggestions box. [#493](https://github.com/sourcebot-dev/sourcebot/pull/493)
1523

docs/docs/connections/gitlab.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview),
9090
"archived": true,
9191
// projects that are forks
9292
"forks": true,
93+
// projects that are owned by users (not groups)
94+
"userOwnedProjects": true,
9395
// projects that match these glob patterns
9496
"projects": [
9597
"my-group/foo/**",

docs/snippets/schemas/v3/connection.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@
347347
"default": false,
348348
"description": "Exclude archived projects from syncing."
349349
},
350+
"userOwnedProjects": {
351+
"type": "boolean",
352+
"default": false,
353+
"description": "Exclude user-owned projects from syncing."
354+
},
350355
"projects": {
351356
"type": "array",
352357
"items": {

docs/snippets/schemas/v3/gitlab.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@
128128
"default": false,
129129
"description": "Exclude archived projects from syncing."
130130
},
131+
"userOwnedProjects": {
132+
"type": "boolean",
133+
"default": false,
134+
"description": "Exclude user-owned projects from syncing."
135+
},
131136
"projects": {
132137
"type": "array",
133138
"items": {

docs/snippets/schemas/v3/index.schema.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@
610610
"default": false,
611611
"description": "Exclude archived projects from syncing."
612612
},
613+
"userOwnedProjects": {
614+
"type": "boolean",
615+
"default": false,
616+
"description": "Exclude user-owned projects from syncing."
617+
},
613618
"projects": {
614619
"type": "array",
615620
"items": {

packages/backend/src/git.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ export const cloneRepository = async (
2727
);
2828

2929
await unsetGitConfig(path, ["remote.origin.url"]);
30-
31-
await git.cwd({
32-
path,
33-
}).addConfig("remote.origin.fetch", "+refs/heads/*:refs/heads/*");
3430
} catch (error: unknown) {
3531
const baseLog = `Failed to clone repository: ${path}`;
3632

@@ -59,6 +55,7 @@ export const fetchRepository = async (
5955

6056
await git.fetch([
6157
remoteUrl.toString(),
58+
"+refs/heads/*:refs/heads/*",
6259
"--prune",
6360
"--progress"
6461
]);

packages/backend/src/gitlab.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,30 @@ test('shouldExcludeProject returns true when the project is excluded by exclude.
4141
})).toBe(true)
4242
});
4343

44+
test('shouldExcludeProject returns true when the project is excluded by exclude.userOwnedProjects.', () => {
45+
const project = {
46+
path_with_namespace: 'test/project',
47+
namespace: {
48+
kind: 'user',
49+
}
50+
} as unknown as ProjectSchema;
51+
52+
expect(shouldExcludeProject({
53+
project,
54+
exclude: {
55+
userOwnedProjects: true,
56+
}
57+
})).toBe(true)
58+
});
59+
60+
test('shouldExcludeProject returns false when exclude.userOwnedProjects is true but project is group-owned.', () => {
61+
const project = {
62+
path_with_namespace: 'test/project',
63+
namespace: { kind: 'group' },
64+
} as unknown as ProjectSchema;
65+
66+
expect(shouldExcludeProject({
67+
project,
68+
exclude: { userOwnedProjects: true },
69+
})).toBe(false);
70+
});

packages/backend/src/gitlab.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ export const shouldExcludeProject = ({
222222
return true;
223223
}
224224

225+
if (exclude?.userOwnedProjects && project.namespace.kind === 'user') {
226+
reason = `\`exclude.userOwnedProjects\` is true`;
227+
return true;
228+
}
229+
225230
if (exclude?.projects) {
226231
if (micromatch.isMatch(projectName, exclude.projects)) {
227232
reason = `\`exclude.projects\` contains ${projectName}`;

packages/schemas/src/v3/connection.schema.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ const schema = {
346346
"default": false,
347347
"description": "Exclude archived projects from syncing."
348348
},
349+
"userOwnedProjects": {
350+
"type": "boolean",
351+
"default": false,
352+
"description": "Exclude user-owned projects from syncing."
353+
},
349354
"projects": {
350355
"type": "array",
351356
"items": {

packages/schemas/src/v3/connection.type.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ export interface GitlabConnectionConfig {
153153
* Exclude archived projects from syncing.
154154
*/
155155
archived?: boolean;
156+
/**
157+
* Exclude user-owned projects from syncing.
158+
*/
159+
userOwnedProjects?: boolean;
156160
/**
157161
* List of projects to exclude from syncing. Glob patterns are supported. The project's namespace must be specified, see: https://docs.gitlab.com/ee/user/namespace/
158162
*/

0 commit comments

Comments
 (0)