Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: Branch used does not throw error

Andras Bacsaida018a8f2ac5
diff --git a/src/routes/applications/[id]/configuration/_GithubRepositories.svelte b/src/routes/applications/[id]/configuration/_GithubRepositories.svelte
index 61ef2d6651..43c08f9c18 100644
--- a/src/routes/applications/[id]/configuration/_GithubRepositories.svelte
+++ b/src/routes/applications/[id]/configuration/_GithubRepositories.svelte
@@ -74,13 +74,18 @@
}
async function isBranchAlreadyUsed() {
try {
- return await get(
+ const data = await get(
`/applications/${id}/configuration/repository.json?repository=${selected.repository}&branch=${selected.branch}`
);
+ if (data.used) {
+ errorNotification('This branch is already used by another application.');
+ showSave = false;
+ return true;
+ }
+ showSave = true;
} catch ({ error }) {
+ showSave = false;
return errorNotification(error);
- } finally {
- showSave = true;
}
}
diff --git a/src/routes/applications/[id]/configuration/_GitlabRepositories.svelte b/src/routes/applications/[id]/configuration/_GitlabRepositories.svelte
index fb1dd602b0..132c3b5228 100644
--- a/src/routes/applications/[id]/configuration/_GitlabRepositories.svelte
+++ b/src/routes/applications/[id]/configuration/_GitlabRepositories.svelte
@@ -132,14 +132,18 @@
}
async function isBranchAlreadyUsed() {
- const url = `/applications/${id}/configuration/repository.json?repository=${selected.project.path_with_namespace}&branch=${selected.branch.name}`;
-
try {
- await get(url);
+ const data = await get(
+ `/applications/${id}/configuration/repository.json?repository=${selected.project.path_with_namespace}&branch=${selected.branch.name}`
+ );
+ if (data.used) {
+ errorNotification('This branch is already used by another application.');
+ showSave = false;
+ return true;
+ }
showSave = true;
- } catch (error) {
- showSave = false;
- return errorNotification('Branch already configured');
+ } catch ({ error }) {
+ return errorNotification(error);
}
}
async function checkSSHKey(sshkeyUrl) {
@@ -195,7 +199,6 @@
const deployKeyFound = deployKeys.filter((dk) => dk.title === `${appId}-coolify-deploy-key`);
if (deployKeyFound.length > 0) {
for (const deployKey of deployKeyFound) {
- console.log(`${deployKeyUrl}/${deployKey.id}`);
await del(
`${deployKeyUrl}/${deployKey.id}`,
{},
diff --git a/src/routes/applications/[id]/configuration/repository.json.ts b/src/routes/applications/[id]/configuration/repository.json.ts
index c462fa5a4b..6d133f29f7 100644
--- a/src/routes/applications/[id]/configuration/repository.json.ts
+++ b/src/routes/applications/[id]/configuration/repository.json.ts
@@ -14,13 +14,11 @@ export const get: RequestHandler = async (event) => {
try {
const found = await db.isBranchAlreadyUsed({ repository, branch, id });
- if (found) {
- throw {
- error: `Branch ${branch} is already used by another application`
- };
- }
return {
- status: 200
+ status: 200,
+ body: {
+ used: found ? true : false
+ }
};
} catch (error) {
return ErrorHandler(error);