Skip to content

Commit 386a3b5

Browse files
remove git & local schemas (#213)
1 parent 50b94b2 commit 386a3b5

17 files changed

+5
-838
lines changed

packages/backend/src/connectionManager.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ export class ConnectionManager implements IConnectionManager {
142142
case 'gerrit': {
143143
return await compileGerritConfig(config, job.data.connectionId, orgId);
144144
}
145-
default: {
146-
return {repoData: [], notFound: {
147-
users: [],
148-
orgs: [],
149-
repos: [],
150-
}};
151-
}
152145
}
153146
})();
154147
} catch (err) {

packages/backend/src/gerrit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fetch from 'cross-fetch';
22
import { GerritConfig } from "@sourcebot/schemas/v2/index.type"
33
import { createLogger } from './logger.js';
44
import micromatch from "micromatch";
5-
import { measure, marshalBool, excludeReposByName, includeReposByName, fetchWithRetry } from './utils.js';
5+
import { measure, fetchWithRetry } from './utils.js';
66
import { BackendError } from '@sourcebot/error';
77
import { BackendException } from '@sourcebot/error';
88

packages/backend/src/git.ts

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import { GitRepository, AppContext } from './types.js';
21
import { simpleGit, SimpleGitProgressEvent } from 'simple-git';
3-
import { createLogger } from './logger.js';
4-
import { GitConfig } from "@sourcebot/schemas/v2/index.type"
5-
import path from 'path';
6-
7-
const logger = createLogger('git');
82

93
export const cloneRepository = async (cloneURL: string, path: string, gitConfig?: Record<string, string>, onProgress?: (event: SimpleGitProgressEvent) => void) => {
104
const git = simpleGit({
@@ -45,80 +39,3 @@ export const fetchRepository = async (path: string, onProgress?: (event: SimpleG
4539
]
4640
);
4741
}
48-
49-
const isValidGitRepo = async (url: string): Promise<boolean> => {
50-
const git = simpleGit();
51-
try {
52-
await git.listRemote([url]);
53-
return true;
54-
} catch (error) {
55-
logger.debug(`Error checking if ${url} is a valid git repo: ${error}`);
56-
return false;
57-
}
58-
}
59-
60-
const stripProtocolAndGitSuffix = (url: string): string => {
61-
return url.replace(/^[a-zA-Z]+:\/\//, '').replace(/\.git$/, '');
62-
}
63-
64-
const getRepoNameFromUrl = (url: string): string => {
65-
const strippedUrl = stripProtocolAndGitSuffix(url);
66-
return strippedUrl.split('/').slice(-2).join('/');
67-
}
68-
69-
export const getGitRepoFromConfig = async (config: GitConfig, ctx: AppContext) => {
70-
const repoValid = await isValidGitRepo(config.url);
71-
if (!repoValid) {
72-
logger.error(`Git repo provided in config with url ${config.url} is not valid`);
73-
return null;
74-
}
75-
76-
const cloneUrl = config.url;
77-
const repoId = stripProtocolAndGitSuffix(cloneUrl);
78-
const repoName = getRepoNameFromUrl(config.url);
79-
const repoPath = path.resolve(path.join(ctx.reposPath, `${repoId}.git`));
80-
const repo: GitRepository = {
81-
vcs: 'git',
82-
id: repoId,
83-
name: repoName,
84-
path: repoPath,
85-
isStale: false,
86-
cloneUrl: cloneUrl,
87-
branches: [],
88-
tags: [],
89-
}
90-
91-
if (config.revisions) {
92-
if (config.revisions.branches) {
93-
const branchGlobs = config.revisions.branches;
94-
const git = simpleGit();
95-
const branchList = await git.listRemote(['--heads', cloneUrl]);
96-
const branches = branchList
97-
.split('\n')
98-
.map(line => line.split('\t')[1])
99-
.filter(Boolean)
100-
.map(branch => branch.replace('refs/heads/', ''));
101-
102-
repo.branches = branches.filter(branch =>
103-
branchGlobs.some(glob => new RegExp(glob).test(branch))
104-
);
105-
}
106-
107-
if (config.revisions.tags) {
108-
const tagGlobs = config.revisions.tags;
109-
const git = simpleGit();
110-
const tagList = await git.listRemote(['--tags', cloneUrl]);
111-
const tags = tagList
112-
.split('\n')
113-
.map(line => line.split('\t')[1])
114-
.filter(Boolean)
115-
.map(tag => tag.replace('refs/tags/', ''));
116-
117-
repo.tags = tags.filter(tag =>
118-
tagGlobs.some(glob => new RegExp(glob).test(tag))
119-
);
120-
}
121-
}
122-
123-
return repo;
124-
}

packages/backend/src/local.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

packages/backend/src/types.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,3 @@
1-
/**
2-
* @deprecated in V3
3-
*/
4-
interface BaseRepository {
5-
vcs: 'git' | 'local';
6-
id: string;
7-
name: string;
8-
path: string;
9-
isStale: boolean;
10-
lastIndexedDate?: string;
11-
isFork?: boolean;
12-
isArchived?: boolean;
13-
codeHost?: string;
14-
topics?: string[];
15-
sizeInBytes?: number;
16-
tenantId?: number;
17-
}
18-
19-
/**
20-
* @deprecated in V3
21-
*/
22-
export interface GitRepository extends BaseRepository {
23-
vcs: 'git';
24-
cloneUrl: string;
25-
branches: string[];
26-
tags: string[];
27-
gitConfigMetadata?: Record<string, string>;
28-
}
29-
30-
/**
31-
* @deprecated in V3
32-
*/
33-
export interface LocalRepository extends BaseRepository {
34-
vcs: 'local';
35-
excludedPaths: string[];
36-
watch: boolean;
37-
}
38-
39-
/**
40-
* @deprecated in V3
41-
*/
42-
export type Repository = GitRepository | LocalRepository;
43-
441
export type AppContext = {
452
/**
463
* Path to the repos cache directory.

0 commit comments

Comments
 (0)