mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
feat(gitlab): Add exclude.userOwnedProjects config setting (#498)
This commit is contained in:
parent
b05fc7a0c8
commit
7d0c6588e1
14 changed files with 84 additions and 0 deletions
|
|
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Added `exclude.userOwnedProjects` setting to GitLab configs. [#498](https://github.com/sourcebot-dev/sourcebot/pull/498)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed "couldn't find remote ref HEAD" errors when re-indexing certain repositories. [#497](https://github.com/sourcebot-dev/sourcebot/pull/497)
|
- Fixed "couldn't find remote ref HEAD" errors when re-indexing certain repositories. [#497](https://github.com/sourcebot-dev/sourcebot/pull/497)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@ If you're not familiar with Sourcebot [connections](/docs/connections/overview),
|
||||||
"archived": true,
|
"archived": true,
|
||||||
// projects that are forks
|
// projects that are forks
|
||||||
"forks": true,
|
"forks": true,
|
||||||
|
// projects that are owned by users (not groups)
|
||||||
|
"userOwnedProjects": true,
|
||||||
// projects that match these glob patterns
|
// projects that match these glob patterns
|
||||||
"projects": [
|
"projects": [
|
||||||
"my-group/foo/**",
|
"my-group/foo/**",
|
||||||
|
|
|
||||||
|
|
@ -343,6 +343,11 @@
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Exclude archived projects from syncing."
|
"description": "Exclude archived projects from syncing."
|
||||||
},
|
},
|
||||||
|
"userOwnedProjects": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Exclude user-owned projects from syncing."
|
||||||
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,11 @@
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Exclude archived projects from syncing."
|
"description": "Exclude archived projects from syncing."
|
||||||
},
|
},
|
||||||
|
"userOwnedProjects": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Exclude user-owned projects from syncing."
|
||||||
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
|
||||||
|
|
@ -606,6 +606,11 @@
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Exclude archived projects from syncing."
|
"description": "Exclude archived projects from syncing."
|
||||||
},
|
},
|
||||||
|
"userOwnedProjects": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Exclude user-owned projects from syncing."
|
||||||
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
|
||||||
|
|
@ -41,3 +41,30 @@ test('shouldExcludeProject returns true when the project is excluded by exclude.
|
||||||
})).toBe(true)
|
})).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);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,11 @@ export const shouldExcludeProject = ({
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exclude?.userOwnedProjects && project.namespace.kind === 'user') {
|
||||||
|
reason = `\`exclude.userOwnedProjects\` is true`;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (exclude?.projects) {
|
if (exclude?.projects) {
|
||||||
if (micromatch.isMatch(projectName, exclude.projects)) {
|
if (micromatch.isMatch(projectName, exclude.projects)) {
|
||||||
reason = `\`exclude.projects\` contains ${projectName}`;
|
reason = `\`exclude.projects\` contains ${projectName}`;
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,11 @@ const schema = {
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Exclude archived projects from syncing."
|
"description": "Exclude archived projects from syncing."
|
||||||
},
|
},
|
||||||
|
"userOwnedProjects": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Exclude user-owned projects from syncing."
|
||||||
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,10 @@ export interface GitlabConnectionConfig {
|
||||||
* Exclude archived projects from syncing.
|
* Exclude archived projects from syncing.
|
||||||
*/
|
*/
|
||||||
archived?: boolean;
|
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/
|
* 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/
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,11 @@ const schema = {
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Exclude archived projects from syncing."
|
"description": "Exclude archived projects from syncing."
|
||||||
},
|
},
|
||||||
|
"userOwnedProjects": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Exclude user-owned projects from syncing."
|
||||||
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ export interface GitlabConnectionConfig {
|
||||||
* Exclude archived projects from syncing.
|
* Exclude archived projects from syncing.
|
||||||
*/
|
*/
|
||||||
archived?: boolean;
|
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/
|
* 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/
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -605,6 +605,11 @@ const schema = {
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Exclude archived projects from syncing."
|
"description": "Exclude archived projects from syncing."
|
||||||
},
|
},
|
||||||
|
"userOwnedProjects": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Exclude user-owned projects from syncing."
|
||||||
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,10 @@ export interface GitlabConnectionConfig {
|
||||||
* Exclude archived projects from syncing.
|
* Exclude archived projects from syncing.
|
||||||
*/
|
*/
|
||||||
archived?: boolean;
|
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/
|
* 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/
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,11 @@
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Exclude archived projects from syncing."
|
"description": "Exclude archived projects from syncing."
|
||||||
},
|
},
|
||||||
|
"userOwnedProjects": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Exclude user-owned projects from syncing."
|
||||||
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue