feat(gitlab): Add exclude.userOwnedProjects config setting (#498)

This commit is contained in:
Brendan Kellam 2025-09-08 22:38:18 -04:00 committed by GitHub
parent b05fc7a0c8
commit 7d0c6588e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 84 additions and 0 deletions

View file

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Added `exclude.userOwnedProjects` setting to GitLab configs. [#498](https://github.com/sourcebot-dev/sourcebot/pull/498)
### Fixed
- Fixed "couldn't find remote ref HEAD" errors when re-indexing certain repositories. [#497](https://github.com/sourcebot-dev/sourcebot/pull/497)

View file

@ -90,6 +90,8 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview),
"archived": true,
// projects that are forks
"forks": true,
// projects that are owned by users (not groups)
"userOwnedProjects": true,
// projects that match these glob patterns
"projects": [
"my-group/foo/**",

View file

@ -343,6 +343,11 @@
"default": false,
"description": "Exclude archived projects from syncing."
},
"userOwnedProjects": {
"type": "boolean",
"default": false,
"description": "Exclude user-owned projects from syncing."
},
"projects": {
"type": "array",
"items": {

View file

@ -126,6 +126,11 @@
"default": false,
"description": "Exclude archived projects from syncing."
},
"userOwnedProjects": {
"type": "boolean",
"default": false,
"description": "Exclude user-owned projects from syncing."
},
"projects": {
"type": "array",
"items": {

View file

@ -606,6 +606,11 @@
"default": false,
"description": "Exclude archived projects from syncing."
},
"userOwnedProjects": {
"type": "boolean",
"default": false,
"description": "Exclude user-owned projects from syncing."
},
"projects": {
"type": "array",
"items": {

View file

@ -41,3 +41,30 @@ test('shouldExcludeProject returns true when the project is excluded by exclude.
})).toBe(true)
});
test('shouldExcludeProject returns true when the project is excluded by exclude.userOwnedProjects.', () => {
const project = {
path_with_namespace: 'test/project',
namespace: {
kind: 'user',
}
} as unknown as ProjectSchema;
expect(shouldExcludeProject({
project,
exclude: {
userOwnedProjects: true,
}
})).toBe(true)
});
test('shouldExcludeProject returns false when exclude.userOwnedProjects is true but project is group-owned.', () => {
const project = {
path_with_namespace: 'test/project',
namespace: { kind: 'group' },
} as unknown as ProjectSchema;
expect(shouldExcludeProject({
project,
exclude: { userOwnedProjects: true },
})).toBe(false);
});

View file

@ -222,6 +222,11 @@ export const shouldExcludeProject = ({
return true;
}
if (exclude?.userOwnedProjects && project.namespace.kind === 'user') {
reason = `\`exclude.userOwnedProjects\` is true`;
return true;
}
if (exclude?.projects) {
if (micromatch.isMatch(projectName, exclude.projects)) {
reason = `\`exclude.projects\` contains ${projectName}`;

View file

@ -342,6 +342,11 @@ const schema = {
"default": false,
"description": "Exclude archived projects from syncing."
},
"userOwnedProjects": {
"type": "boolean",
"default": false,
"description": "Exclude user-owned projects from syncing."
},
"projects": {
"type": "array",
"items": {

View file

@ -153,6 +153,10 @@ export interface GitlabConnectionConfig {
* Exclude archived projects from syncing.
*/
archived?: boolean;
/**
* Exclude user-owned projects from syncing.
*/
userOwnedProjects?: boolean;
/**
* 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/
*/

View file

@ -125,6 +125,11 @@ const schema = {
"default": false,
"description": "Exclude archived projects from syncing."
},
"userOwnedProjects": {
"type": "boolean",
"default": false,
"description": "Exclude user-owned projects from syncing."
},
"projects": {
"type": "array",
"items": {

View file

@ -56,6 +56,10 @@ export interface GitlabConnectionConfig {
* Exclude archived projects from syncing.
*/
archived?: boolean;
/**
* Exclude user-owned projects from syncing.
*/
userOwnedProjects?: boolean;
/**
* 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/
*/

View file

@ -605,6 +605,11 @@ const schema = {
"default": false,
"description": "Exclude archived projects from syncing."
},
"userOwnedProjects": {
"type": "boolean",
"default": false,
"description": "Exclude user-owned projects from syncing."
},
"projects": {
"type": "array",
"items": {

View file

@ -278,6 +278,10 @@ export interface GitlabConnectionConfig {
* Exclude archived projects from syncing.
*/
archived?: boolean;
/**
* Exclude user-owned projects from syncing.
*/
userOwnedProjects?: boolean;
/**
* 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/
*/

View file

@ -97,6 +97,11 @@
"default": false,
"description": "Exclude archived projects from syncing."
},
"userOwnedProjects": {
"type": "boolean",
"default": false,
"description": "Exclude user-owned projects from syncing."
},
"projects": {
"type": "array",
"items": {