Skip to content

add back gitlab, gitea, and gerrit support #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 14, 2025
Prev Previous commit
Next Next commit
wip gitlab repo sync support
  • Loading branch information
msukkari committed Feb 10, 2025
commit c64a32fe4fdacea38fd59852db36dfef4edb651f
4 changes: 2 additions & 2 deletions packages/backend/src/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ export const shouldExcludeProject = ({
}: {
project: ProjectSchema,
include?: {
topics?: GitLabConfig['topics'],
topics?: GitlabConnectionConfig['topics'],
},
exclude?: GitLabConfig['exclude'],
exclude?: GitlabConnectionConfig['exclude'],
}) => {
const projectName = project.path_with_namespace;
let reason = '';
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/repoCompileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const compileGitlabConfig = async (
return gitlabRepos.map((project) => {
const projectName = `${config.url}/${project.full_name}`;
const projectUrl = `${hostUrl}/${project.path_with_namespace}`;
const cloneUrl = new URL(project.clone_url!);
const cloneUrl = new URL(project.http_url_to_repo);
const isFork = project.forked_from_project !== undefined;

const record: RepoData = {
Expand Down Expand Up @@ -106,5 +106,5 @@ export const compileGitlabConfig = async (
};

return record;
}
})
}
11 changes: 8 additions & 3 deletions packages/backend/src/repoManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Job, Queue, Worker } from 'bullmq';
import { Redis } from 'ioredis';
import { createLogger } from "./logger.js";
import { Connection, PrismaClient, Repo, RepoToConnection, RepoIndexingStatus } from "@sourcebot/db";
import { ConnectionConfig } from '@sourcebot/schemas/v3/connection.type';
import { GithubConnectionConfig, GitlabConnectionConfig, GiteaConnectionConfig } from '@sourcebot/schemas/v3/connection.type';
import { AppContext, Settings } from "./types.js";
import { captureEvent } from "./posthog.js";
import { getRepoPath, getTokenFromConfig, measure, getShardPrefix } from "./utils.js";
Expand Down Expand Up @@ -74,7 +74,7 @@ export class RepoManager implements IRepoManager {
const repos = await this.db.repo.findMany({
where: {
repoIndexingStatus: {
notIn: [RepoIndexingStatus.IN_INDEX_QUEUE, RepoIndexingStatus.FAILED]
notIn: [RepoIndexingStatus.IN_INDEX_QUEUE, RepoIndexingStatus.INDEXING, RepoIndexingStatus.FAILED]
},
OR: [
{ indexedAt: null },
Expand Down Expand Up @@ -147,10 +147,15 @@ export class RepoManager implements IRepoManager {
return;
}


let token: string | undefined;
for (const repoConnection of repoConnections) {
const connection = repoConnection.connection;
const config = connection.config as unknown as ConnectionConfig;
if (connection.connectionType !== 'github' && connection.connectionType !== 'gitlab' && connection.connectionType !== 'gitea') {
continue;
}

const config = connection.config as unknown as GithubConnectionConfig | GitlabConnectionConfig | GiteaConnectionConfig;
if (config.token) {
token = await getTokenFromConfig(config.token, connection.orgId, db);
if (token) {
Expand Down