Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions docs/docs/connections/gitlab.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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/**",
Expand Down
5 changes: 5 additions & 0 deletions docs/snippets/schemas/v3/connection.schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions docs/snippets/schemas/v3/gitlab.schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions docs/snippets/schemas/v3/index.schema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
15 changes: 15 additions & 0 deletions packages/backend/src/gitlab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,18 @@ 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)
});
Comment thread
brendan-kellam marked this conversation as resolved.
5 changes: 5 additions & 0 deletions packages/backend/src/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ export const shouldExcludeProject = ({
return true;
}

if (exclude?.userOwnedProjects && project.namespace.kind === 'user') {
reason = `\`exclude.userOwnedProjects\` is true`;
return true;
}
Comment thread
brendan-kellam marked this conversation as resolved.

if (exclude?.projects) {
if (micromatch.isMatch(projectName, exclude.projects)) {
reason = `\`exclude.projects\` contains ${projectName}`;
Expand Down
5 changes: 5 additions & 0 deletions packages/schemas/src/v3/connection.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions packages/schemas/src/v3/connection.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/schemas/src/v3/gitlab.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions packages/schemas/src/v3/gitlab.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/schemas/src/v3/index.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions packages/schemas/src/v3/index.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*/
Expand Down
5 changes: 5 additions & 0 deletions schemas/v3/gitlab.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down