MCPcopy
hub / github.com/Dokploy/dokploy / ensurePatchRepo

Function ensurePatchRepo

packages/server/src/services/patch-repo.ts:22–71  ·  view source on GitHub ↗
({
	type,
	id,
}: PatchRepoConfig)

Source from the content-addressed store, hash-verified

20 * Returns path to the repo
21 */
22export const ensurePatchRepo = async ({
23 type,
24 id,
25}: PatchRepoConfig): Promise<string> => {
26 let serverId: string | null = null;
27
28 if (type === "application") {
29 const application = await findApplicationById(id);
30 serverId = application.buildServerId || application.serverId;
31 } else {
32 const compose = await findComposeById(id);
33 serverId = compose.serverId;
34 }
35
36 const application =
37 type === "application"
38 ? await findApplicationById(id)
39 : await findComposeById(id);
40
41 const { PATCH_REPOS_PATH } = paths(!!serverId);
42 const repoPath = join(PATCH_REPOS_PATH, type, application.appName);
43
44 const applicationEntity = {
45 ...application,
46 type,
47 serverId: serverId,
48 outputPathOverride: repoPath,
49 };
50
51 let command = "set -e;";
52 if (application.sourceType === "github") {
53 command += await cloneGithubRepository(applicationEntity);
54 } else if (application.sourceType === "gitlab") {
55 command += await cloneGitlabRepository(applicationEntity);
56 } else if (application.sourceType === "gitea") {
57 command += await cloneGiteaRepository(applicationEntity);
58 } else if (application.sourceType === "bitbucket") {
59 command += await cloneBitbucketRepository(applicationEntity);
60 } else if (application.sourceType === "git") {
61 command += await cloneGitRepository(applicationEntity);
62 }
63
64 if (serverId) {
65 await execAsyncRemote(serverId, command);
66 } else {
67 await execAsync(command);
68 }
69
70 return repoPath;
71};
72
73interface DirectoryEntry {
74 name: string;

Callers 1

patch.tsFile · 0.90

Calls 10

findApplicationByIdFunction · 0.90
findComposeByIdFunction · 0.90
pathsFunction · 0.90
cloneGithubRepositoryFunction · 0.90
cloneGitlabRepositoryFunction · 0.90
cloneGiteaRepositoryFunction · 0.90
cloneBitbucketRepositoryFunction · 0.90
cloneGitRepositoryFunction · 0.90
execAsyncRemoteFunction · 0.90
execAsyncFunction · 0.90

Tested by

no test coverage detected