Skip to content

Commit c64a32f

Browse files
committed
wip gitlab repo sync support
1 parent b5dc898 commit c64a32f

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

packages/backend/src/gitlab.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ export const shouldExcludeProject = ({
118118
}: {
119119
project: ProjectSchema,
120120
include?: {
121-
topics?: GitLabConfig['topics'],
121+
topics?: GitlabConnectionConfig['topics'],
122122
},
123-
exclude?: GitLabConfig['exclude'],
123+
exclude?: GitlabConnectionConfig['exclude'],
124124
}) => {
125125
const projectName = project.path_with_namespace;
126126
let reason = '';

packages/backend/src/repoCompileUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const compileGitlabConfig = async (
7070
return gitlabRepos.map((project) => {
7171
const projectName = `${config.url}/${project.full_name}`;
7272
const projectUrl = `${hostUrl}/${project.path_with_namespace}`;
73-
const cloneUrl = new URL(project.clone_url!);
73+
const cloneUrl = new URL(project.http_url_to_repo);
7474
const isFork = project.forked_from_project !== undefined;
7575

7676
const record: RepoData = {
@@ -106,5 +106,5 @@ export const compileGitlabConfig = async (
106106
};
107107

108108
return record;
109-
}
109+
})
110110
}

packages/backend/src/repoManager.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Job, Queue, Worker } from 'bullmq';
22
import { Redis } from 'ioredis';
33
import { createLogger } from "./logger.js";
44
import { Connection, PrismaClient, Repo, RepoToConnection, RepoIndexingStatus } from "@sourcebot/db";
5-
import { ConnectionConfig } from '@sourcebot/schemas/v3/connection.type';
5+
import { GithubConnectionConfig, GitlabConnectionConfig, GiteaConnectionConfig } from '@sourcebot/schemas/v3/connection.type';
66
import { AppContext, Settings } from "./types.js";
77
import { captureEvent } from "./posthog.js";
88
import { getRepoPath, getTokenFromConfig, measure, getShardPrefix } from "./utils.js";
@@ -74,7 +74,7 @@ export class RepoManager implements IRepoManager {
7474
const repos = await this.db.repo.findMany({
7575
where: {
7676
repoIndexingStatus: {
77-
notIn: [RepoIndexingStatus.IN_INDEX_QUEUE, RepoIndexingStatus.FAILED]
77+
notIn: [RepoIndexingStatus.IN_INDEX_QUEUE, RepoIndexingStatus.INDEXING, RepoIndexingStatus.FAILED]
7878
},
7979
OR: [
8080
{ indexedAt: null },
@@ -147,10 +147,15 @@ export class RepoManager implements IRepoManager {
147147
return;
148148
}
149149

150+
150151
let token: string | undefined;
151152
for (const repoConnection of repoConnections) {
152153
const connection = repoConnection.connection;
153-
const config = connection.config as unknown as ConnectionConfig;
154+
if (connection.connectionType !== 'github' && connection.connectionType !== 'gitlab' && connection.connectionType !== 'gitea') {
155+
continue;
156+
}
157+
158+
const config = connection.config as unknown as GithubConnectionConfig | GitlabConnectionConfig | GiteaConnectionConfig;
154159
if (config.token) {
155160
token = await getTokenFromConfig(config.token, connection.orgId, db);
156161
if (token) {

0 commit comments

Comments
 (0)