Skip to content

Commit 3b61138

Browse files
committed
handle case where gerrit weburl is just gitiles path
1 parent 82f9d8b commit 3b61138

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/backend/src/repoCompileUtils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export const compileGerritConfig = async (
212212
orgId: number) => {
213213

214214
const gerritRepos = await getGerritReposFromConfig(config);
215-
const hostUrl = config.url ?? 'https://gerritcodereview.com';
215+
const hostUrl = (config.url ?? 'https://gerritcodereview.com').replace(/\/$/, ''); // Remove trailing slash
216216
const hostname = new URL(hostUrl).hostname;
217217

218218
const repos = gerritRepos.map((project) => {
@@ -228,6 +228,12 @@ export const compileGerritConfig = async (
228228
}
229229
}
230230

231+
// Handle case where webUrl is just a gitiles path
232+
// https://github.com/GerritCodeReview/plugins_gitiles/blob/5ee7f57/src/main/java/com/googlesource/gerrit/plugins/gitiles/GitilesWeblinks.java#L50
233+
if (webUrl.startsWith('/plugins/gitiles/')) {
234+
webUrl = `${hostUrl}${webUrl}`;
235+
}
236+
231237
const record: RepoData = {
232238
external_id: project.id.toString(),
233239
external_codeHostType: 'gerrit',

0 commit comments

Comments
 (0)