mirror of
https://github.com/andwati/dokploy.git
synced 2026-12-01 15:28:49 +00:00
Merge pull request #2532 from monntterro/feat/gitea-http-support
feat: support cloning repositories over HTTP in Gitea integration
This commit is contained in:
@@ -99,6 +99,19 @@ export const refreshGiteaToken = async (giteaProviderId: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buildGiteaCloneUrl = (
|
||||||
|
giteaUrl: string,
|
||||||
|
accessToken: string,
|
||||||
|
owner: string,
|
||||||
|
repository: string,
|
||||||
|
) => {
|
||||||
|
const protocol = giteaUrl.startsWith("http://") ? "http" : "https";
|
||||||
|
const baseUrl = giteaUrl.replace(/^https?:\/\//, "");
|
||||||
|
const repoClone = `${owner}/${repository}.git`;
|
||||||
|
const cloneUrl = `${protocol}://oauth2:${accessToken}@${baseUrl}/${repoClone}`;
|
||||||
|
return cloneUrl;
|
||||||
|
};
|
||||||
|
|
||||||
export type ApplicationWithGitea = InferResultType<
|
export type ApplicationWithGitea = InferResultType<
|
||||||
"applications",
|
"applications",
|
||||||
{ gitea: true }
|
{ gitea: true }
|
||||||
@@ -148,9 +161,13 @@ export const getGiteaCloneCommand = async (
|
|||||||
const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH;
|
const basePath = isCompose ? COMPOSE_PATH : APPLICATIONS_PATH;
|
||||||
const outputPath = join(basePath, appName, "code");
|
const outputPath = join(basePath, appName, "code");
|
||||||
|
|
||||||
const baseUrl = gitea?.giteaUrl.replace(/^https?:\/\//, "");
|
|
||||||
const repoClone = `${giteaOwner}/${giteaRepository}.git`;
|
const repoClone = `${giteaOwner}/${giteaRepository}.git`;
|
||||||
const cloneUrl = `https://oauth2:${gitea?.accessToken}@${baseUrl}/${repoClone}`;
|
const cloneUrl = buildGiteaCloneUrl(
|
||||||
|
gitea?.giteaUrl!,
|
||||||
|
gitea?.accessToken!,
|
||||||
|
giteaOwner!,
|
||||||
|
giteaRepository!,
|
||||||
|
);
|
||||||
|
|
||||||
const cloneCommand = `
|
const cloneCommand = `
|
||||||
rm -rf ${outputPath};
|
rm -rf ${outputPath};
|
||||||
@@ -205,8 +222,12 @@ export const cloneGiteaRepository = async (
|
|||||||
await recreateDirectory(outputPath);
|
await recreateDirectory(outputPath);
|
||||||
|
|
||||||
const repoClone = `${giteaOwner}/${giteaRepository}.git`;
|
const repoClone = `${giteaOwner}/${giteaRepository}.git`;
|
||||||
const baseUrl = giteaProvider.giteaUrl.replace(/^https?:\/\//, "");
|
const cloneUrl = buildGiteaCloneUrl(
|
||||||
const cloneUrl = `https://oauth2:${giteaProvider.accessToken}@${baseUrl}/${repoClone}`;
|
giteaProvider.giteaUrl,
|
||||||
|
giteaProvider.accessToken!,
|
||||||
|
giteaOwner!,
|
||||||
|
giteaRepository!,
|
||||||
|
);
|
||||||
|
|
||||||
writeStream.write(`\nCloning Repo ${repoClone} to ${outputPath}...\n`);
|
writeStream.write(`\nCloning Repo ${repoClone} to ${outputPath}...\n`);
|
||||||
|
|
||||||
@@ -269,9 +290,12 @@ export const cloneRawGiteaRepository = async (entity: Compose) => {
|
|||||||
const outputPath = join(basePath, appName, "code");
|
const outputPath = join(basePath, appName, "code");
|
||||||
await recreateDirectory(outputPath);
|
await recreateDirectory(outputPath);
|
||||||
|
|
||||||
const repoClone = `${giteaOwner}/${giteaRepository}.git`;
|
const cloneUrl = buildGiteaCloneUrl(
|
||||||
const baseUrl = giteaProvider.giteaUrl.replace(/^https?:\/\//, "");
|
giteaProvider.giteaUrl,
|
||||||
const cloneUrl = `https://oauth2:${giteaProvider.accessToken}@${baseUrl}/${repoClone}`;
|
giteaProvider.accessToken!,
|
||||||
|
giteaOwner!,
|
||||||
|
giteaRepository!,
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await spawnAsync("git", [
|
await spawnAsync("git", [
|
||||||
@@ -317,9 +341,13 @@ export const cloneRawGiteaRepositoryRemote = async (compose: Compose) => {
|
|||||||
const giteaProvider = await findGiteaById(giteaId);
|
const giteaProvider = await findGiteaById(giteaId);
|
||||||
const basePath = COMPOSE_PATH;
|
const basePath = COMPOSE_PATH;
|
||||||
const outputPath = join(basePath, appName, "code");
|
const outputPath = join(basePath, appName, "code");
|
||||||
const repoClone = `${giteaOwner}/${giteaRepository}.git`;
|
const cloneUrl = buildGiteaCloneUrl(
|
||||||
const baseUrl = giteaProvider.giteaUrl.replace(/^https?:\/\//, "");
|
giteaProvider.giteaUrl,
|
||||||
const cloneUrl = `https://oauth2:${giteaProvider.accessToken}@${baseUrl}/${repoClone}`;
|
giteaProvider.accessToken!,
|
||||||
|
giteaOwner!,
|
||||||
|
giteaRepository!,
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const command = `
|
const command = `
|
||||||
rm -rf ${outputPath};
|
rm -rf ${outputPath};
|
||||||
|
|||||||
Reference in New Issue
Block a user