Skip to content

Commit 9e52b72

Browse files
committed
fix(git-provider): use internal URLs for Gitea and GitLab repository cloning
- Updated the repository cloning functions to prioritize internal URLs for Gitea and GitLab, enhancing security and access control. - Ensured fallback to external URLs if internal ones are not available.
1 parent 70418dd commit 9e52b72

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/server/src/utils/providers/gitea.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export const cloneGiteaRepository = async ({
170170

171171
const repoClone = `${giteaOwner}/${giteaRepository}.git`;
172172
const cloneUrl = buildGiteaCloneUrl(
173-
giteaProvider.giteaUrl,
173+
giteaProvider.giteaInternalUrl || giteaProvider.giteaUrl,
174174
giteaProvider.accessToken!,
175175
giteaOwner!,
176176
giteaRepository!,

packages/server/src/utils/providers/gitlab.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ const getGitlabRepoClone = (
9090
gitlab: GitlabInfo,
9191
gitlabPathNamespace: string | null,
9292
) => {
93-
const repoClone = `${gitlab?.gitlabUrl.replace(/^https?:\/\//, "")}/${gitlabPathNamespace}.git`;
93+
const url = gitlab?.gitlabInternalUrl || gitlab?.gitlabUrl;
94+
const repoClone = `${url?.replace(/^https?:\/\//, "")}/${gitlabPathNamespace}.git`;
9495
return repoClone;
9596
};
9697

9798
const getGitlabCloneUrl = (gitlab: GitlabInfo, repoClone: string) => {
98-
const isSecure = gitlab?.gitlabUrl.startsWith("https://");
99+
const url = gitlab?.gitlabInternalUrl || gitlab?.gitlabUrl;
100+
const isSecure = url?.startsWith("https://");
99101
const cloneUrl = `http${isSecure ? "s" : ""}://oauth2:${gitlab?.accessToken}@${repoClone}`;
100102
return cloneUrl;
101103
};

0 commit comments

Comments
 (0)