diff --git a/app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java b/app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java index e36eea10f8..2aa964d5c4 100644 --- a/app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java +++ b/app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java @@ -1268,7 +1268,12 @@ public class FileUtilsCEImpl implements FileInterface { @Override public Mono reconstructPageFromGitRepo( - String pageName, String branchName, Path baseRepoSuffixPath, Boolean resetToLastCommitRequired) { + String pageName, + String branchName, + Path baseRepoSuffixPath, + Boolean resetToLastCommitRequired, + Boolean useFSGitHandler, + Boolean keepWorkingDirChanges) { Mono pageObjectMono; try { Mono resetToLastCommit = Mono.just(Boolean.TRUE); @@ -1276,7 +1281,12 @@ public class FileUtilsCEImpl implements FileInterface { if (Boolean.TRUE.equals(resetToLastCommitRequired)) { // instead of checking out to last branch we are first cleaning the git repo, // then checking out to the desired branch - resetToLastCommit = gitExecutor.resetToLastCommit(baseRepoSuffixPath, branchName, false); + if (Boolean.TRUE.equals(useFSGitHandler)) { + resetToLastCommit = + fsGitHandler.resetToLastCommit(baseRepoSuffixPath, branchName, keepWorkingDirChanges); + } else { + resetToLastCommit = gitExecutor.resetToLastCommit(baseRepoSuffixPath, branchName, true); + } } pageObjectMono = resetToLastCommit.map(isSwitched -> { diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/enums/FeatureFlagEnum.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/enums/FeatureFlagEnum.java index fcb8ab2c15..5aa764d353 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/enums/FeatureFlagEnum.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/enums/FeatureFlagEnum.java @@ -24,6 +24,7 @@ public enum FeatureFlagEnum { * Feature flag to detect if the RTS git reset is enabled */ ab_rts_git_reset_enabled, + release_git_api_contracts_enabled, // Deprecated CE flags over here release_git_autocommit_feature_enabled, diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/FileInterface.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/FileInterface.java index 7d4443f9a2..9203832403 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/FileInterface.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/FileInterface.java @@ -80,7 +80,12 @@ public interface FileInterface { Mono reconstructPackageJsonFromGitRepository(Path repoSuffix); Mono reconstructPageFromGitRepo( - String pageName, String branchName, Path repoSuffixPath, Boolean checkoutRequired); + String pageName, + String branchName, + Path repoSuffixPath, + Boolean checkoutRequired, + Boolean useFSGitHandler, + Boolean keepWorkingDirChanges); /** * Once the user connects the existing application to a remote repo, we will initialize the repo with Readme.md - diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java index fdeae3e1ba..3d52dd1239 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java @@ -933,6 +933,9 @@ public class CommonGitFileUtilsCE { String defaultArtifactId = gitArtifactMetadata.getDefaultArtifactId(); String refName = gitArtifactMetadata.getRefName(); String repoName = gitArtifactMetadata.getRepoName(); + Mono useFSGitHandlerMono = featureFlagService.check(FeatureFlagEnum.release_git_api_contracts_enabled); + Mono keepWorkingDirChangesMono = + featureFlagService.check(FeatureFlagEnum.release_git_reset_optimization_enabled); if (!hasText(workspaceId)) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.WORKSPACE_ID)); @@ -957,8 +960,14 @@ public class CommonGitFileUtilsCE { ArtifactGitFileUtils artifactGitFileUtils = getArtifactBasedFileHelper(artifactType); Path baseRepoSuffix = artifactGitFileUtils.getRepoSuffixPath(workspaceId, defaultArtifactId, repoName); - Mono jsonObjectMono = fileUtils - .reconstructPageFromGitRepo(pageDTO.getName(), refName, baseRepoSuffix, isResetToLastCommitRequired) + Mono jsonObjectMono = Mono.zip(useFSGitHandlerMono, keepWorkingDirChangesMono) + .flatMap(tuple -> fileUtils.reconstructPageFromGitRepo( + pageDTO.getName(), + refName, + baseRepoSuffix, + isResetToLastCommitRequired, + tuple.getT1(), + tuple.getT2())) .onErrorResume(error -> Mono.error( new AppsmithException(AppsmithError.GIT_ACTION_FAILED, RECONSTRUCT_PAGE, error.getMessage()))) .map(pageJson -> {