Skip to content

Commit 5997e19

Browse files
authored
Merge branch 'main' into fix/bitbucket-cloud-pagination-url-parsing
2 parents 33fa1aa + aab4a92 commit 5997e19

File tree

16 files changed

+93
-5
lines changed

16 files changed

+93
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

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

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
@@ -343,6 +343,11 @@
343343
"default": false,
344344
"description": "Exclude archived projects from syncing."
345345
},
346+
"userOwnedProjects": {
347+
"type": "boolean",
348+
"default": false,
349+
"description": "Exclude user-owned projects from syncing."
350+
},
346351
"projects": {
347352
"type": "array",
348353
"items": {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@
126126
"default": false,
127127
"description": "Exclude archived projects from syncing."
128128
},
129+
"userOwnedProjects": {
130+
"type": "boolean",
131+
"default": false,
132+
"description": "Exclude user-owned projects from syncing."
133+
},
129134
"projects": {
130135
"type": "array",
131136
"items": {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,11 @@
606606
"default": false,
607607
"description": "Exclude archived projects from syncing."
608608
},
609+
"userOwnedProjects": {
610+
"type": "boolean",
611+
"default": false,
612+
"description": "Exclude user-owned projects from syncing."
613+
},
609614
"projects": {
610615
"type": "array",
611616
"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/backend/src/zoekt.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ export const indexGitRepository = async (repo: Repo, settings: Settings, ctx: Ap
8484
}
8585
if (stderr) {
8686
stderr.split('\n').filter(line => line.trim()).forEach(line => {
87-
logger.error(line);
87+
// TODO: logging as regular info here and not error because non error logs are being
88+
// streamed in stderr and incorrectly being logged as errors at a high level
89+
logger.info(line);
8890
});
8991
}
9092

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ const schema = {
342342
"default": false,
343343
"description": "Exclude archived projects from syncing."
344344
},
345+
"userOwnedProjects": {
346+
"type": "boolean",
347+
"default": false,
348+
"description": "Exclude user-owned projects from syncing."
349+
},
345350
"projects": {
346351
"type": "array",
347352
"items": {

0 commit comments

Comments
 (0)