diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java index d7bfc5961f..561a35b6f1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java @@ -2781,8 +2781,7 @@ public class CentralGitServiceCEImpl implements CentralGitServiceCE { final String baseArtifactId = baseGitMetadata.getDefaultArtifactId(); final String repoName = baseGitMetadata.getRepoName(); - // 1. Hydrate from db to git system for both ref Artifacts - // Update function call + // 1. Hydrate from db to a git system for both branch artifacts return Mono.usingWhen( gitRedisUtils.acquireGitLock( artifactType, baseArtifactId, GitConstants.GitCommandConstants.MERGE_BRANCH, TRUE), diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java index d87615a1c0..6a5c40bab9 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java @@ -770,11 +770,18 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE { jsonTransformationDTO.getBaseArtifactId(), jsonTransformationDTO.getRepoName()); - // TODO: add the checkout to the current branch as well. - return fsGitHandler.checkoutToBranch(repoSuffix, baseRefName).flatMap(isCheckedOut -> fsGitHandler - .createAndCheckoutReference(repoSuffix, gitRefDTO) - .flatMap(newRef -> fsGitHandler.pushArtifact( - repoSuffix, remoteUrl, publicKey, privateKey, gitRefDTO.getRefName(), incomingRefType))); + return fsGitHandler + .resetToLastCommit(repoSuffix) + .then(fsGitHandler.checkoutToBranch(repoSuffix, baseRefName)) + .flatMap(isCheckedOut -> fsGitHandler + .createAndCheckoutReference(repoSuffix, gitRefDTO) + .flatMap(newRef -> fsGitHandler.pushArtifact( + repoSuffix, + remoteUrl, + publicKey, + privateKey, + gitRefDTO.getRefName(), + incomingRefType))); } @Override @@ -787,7 +794,9 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE { jsonTransformationDTO.getBaseArtifactId(), jsonTransformationDTO.getRepoName()); - return fsGitHandler.checkoutRemoteBranch(repoSuffix, jsonTransformationDTO.getRefName()); + return fsGitHandler + .resetToLastCommit(repoSuffix) + .then(fsGitHandler.checkoutRemoteBranch(repoSuffix, jsonTransformationDTO.getRefName())); } @Override