fix(git_clone): make sure correct urls are shown
+ 9
- 7
app/services/gitServer/onPushEvent.ts
@@ -43,7 +43,7 @@ const makeOnPushEvent: ServiceMethodFactory<
           return updatedRepo;
         });
 
-      const repoUrlPrefix = `${Env.DEPLOYMENT_SCHEME}://${Env.DEPLOYMENT_DOMAIN}${Env.PORT != 80 && Env.PORT != 443 ? `:${Env.PORT}` : ""}`;
+      const repoUrlPrefix = `${Env.DEPLOYMENT_SCHEME}://${Env.DEPLOYMENT_DOMAIN}${Env.DEPLOYMENT_SCHEME !== "https" ? `:${Env.PORT}` : ""}`;
       const repoUrlSuffix = `${orgSlug}/${repoSlug}`;
       const repoUrlBase =
         env === "production"

app/services/repository/getRepositoryHTTPCloneUrl.ts
@@ -21,7 +21,7 @@ const makeGetRepositoryHTTPCloneUrl: ServiceMethodFactory<
 
     if (parentOrg == null) {
       throw new Error(
-        `Could not find the parent organization for project "${repo.slug}".`
+        `Could not find the parent organization for project "${repo.slug}".`,
       );
     }
 

...
@@ -30,7 +30,7 @@ const makeGetRepositoryHTTPCloneUrl: ServiceMethodFactory<
         ? `${parentOrg.slug}:secret@`
         : "";
     const baseUrl = `${Env.DEPLOYMENT_SCHEME}://${authCredentials}${Env.DEPLOYMENT_DOMAIN}`;
-    const port = Env.PORT != 80 && Env.PORT != 443 ? `:${Env.PORT}` : "";
+    const port = Env.DEPLOYMENT_SCHEME !== "https" ? `:${Env.PORT}` : "";
 
     return `${baseUrl}${port}/${parentOrg.slug}/${repo.slug}.git`;
   };

app/services/repository/getRepositorySSHCloneUrl.ts
@@ -3,7 +3,7 @@ import type { ServiceMethodFactory } from "@ethicdevs/react-monolith";
 // generated via script[generate:prisma]
 import type { Repository } from "@prisma/client";
 // app
-// import { Env } from "../../env";
+import { Env } from "../../env";
 // service
 import type { RepositoryServiceDeps } from "./types";
 

...
@@ -21,12 +21,14 @@ const makeGetRepositorySSHCloneUrl: ServiceMethodFactory<
 
     if (parentOrg == null) {
       throw new Error(
-        `Could not find the parent organization for project "${repo.slug}".`
+        `Could not find the parent organization for project "${repo.slug}".`,
       );
     }
 
-    const baseUrl = `git@localhost`;
-    return `${baseUrl}:${parentOrg.slug}/${repo.slug}.git`;
+    // const baseUrl = `git@localhost`;
+    const baseUrl = `git@${Env.DEPLOYMENT_DOMAIN}`;
+    const port = Env.DEPLOYMENT_SCHEME !== "https" ? `:${Env.PORT}/` : ":";
+    return `${baseUrl}${port}${parentOrg.slug}/${repo.slug}.git`;
   };
 };