diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/git/GitApplicationHelperCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/git/GitApplicationHelperCEImpl.java index e59d74b7ae..c299137a10 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/git/GitApplicationHelperCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/git/GitApplicationHelperCEImpl.java @@ -322,4 +322,9 @@ public class GitApplicationHelperCEImpl implements GitArtifactHelperCE publishArtifactPostCommit(Artifact committedArtifact) { return publishArtifact(committedArtifact, true); } + + @Override + public Mono validateAndPublishArtifact(Artifact artifact, boolean publish) { + return publishArtifact(artifact, publish); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java index 93c08cdf24..e9d0c004f6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java @@ -2288,12 +2288,16 @@ public class CommonGitServiceCEImpl implements CommonGitServiceCE { artifactExchangeJson, branchName)) // Update the last deployed status after the rebase - .flatMap(importedArtifact -> publishArtifact(importedArtifact, true)); + .flatMap(importedArtifact -> + gitArtifactHelper.validateAndPublishArtifact(importedArtifact, true)); }) .flatMap(branchedArtifact -> releaseFileLock( branchedArtifact.getGitArtifactMetadata().getDefaultArtifactId()) .then(this.addAnalyticsForGitOperation( AnalyticsEvents.GIT_DISCARD_CHANGES, branchedArtifact, null))) + .onErrorResume(error -> branchedArtifactMonoCached.flatMap(branchedArtifact -> releaseFileLock( + branchedArtifact.getGitArtifactMetadata().getDefaultArtifactId()) + .then(Mono.error(error)))) .name(GitSpan.OPS_DISCARD_CHANGES) .tap(Micrometer.observation(observationRegistry)); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitArtifactHelperCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitArtifactHelperCE.java index 346c0149b4..8f436fc18d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitArtifactHelperCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitArtifactHelperCE.java @@ -68,4 +68,6 @@ public interface GitArtifactHelperCE { T getNewArtifact(String workspaceId, String repoName); Mono publishArtifactPostCommit(Artifact committedArtifact); + + Mono validateAndPublishArtifact(Artifact artifact, boolean publish); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/testhelpers/git/GitFileSystemTestHelper.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/testhelpers/git/GitFileSystemTestHelper.java index f55c768fc0..3a3d1f681a 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/testhelpers/git/GitFileSystemTestHelper.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/testhelpers/git/GitFileSystemTestHelper.java @@ -64,6 +64,18 @@ public class GitFileSystemTestHelper { // checkout to the new branch gitExecutor.createAndCheckoutToBranch(suffix, branchName).block(); + commitArtifact(workspaceId, applicationId, branchName, repoName, applicationJson, "commit message two"); + } + + public void commitArtifact( + String workspaceId, + String applicationId, + String branchName, + String repoName, + ApplicationJson applicationJson, + String commitMessage) + throws GitAPIException, IOException { + Path suffix = Paths.get(workspaceId, applicationId, repoName); // saving the files into the git repository from application json // The files would later be saved in this git repository from resources section instead of applicationJson commonGitFileUtils @@ -72,7 +84,7 @@ public class GitFileSystemTestHelper { // commit the application gitExecutor - .commitArtifact(suffix, "commit message two", "user", "user@domain.xy", true, false) + .commitArtifact(suffix, commitMessage, "user", "user@domain.xy", true, false) .block(); }