chore: remove extra reset in auto-commit (#40405)

## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/14725742815>
> Commit: 9c004ca65ac0842a24dea725dde539c176a6dba6
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14725742815&attempt=3"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Wed, 30 Apr 2025 05:08:47 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced a new feature flag to control the enablement of updated Git
API contracts.
- **Enhancements**
- Improved the logic for reconstructing pages from Git repositories,
allowing for more granular control based on feature flags.
- Enhanced compatibility with future Git-related optimizations by adding
support for additional parameters in page reconstruction operations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Diljit 2025-05-05 09:40:45 +05:30 committed by GitHub
parent 60b6aed220
commit 3212d738ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 5 deletions

View File

@ -1268,7 +1268,12 @@ public class FileUtilsCEImpl implements FileInterface {
@Override
public Mono<Object> reconstructPageFromGitRepo(
String pageName, String branchName, Path baseRepoSuffixPath, Boolean resetToLastCommitRequired) {
String pageName,
String branchName,
Path baseRepoSuffixPath,
Boolean resetToLastCommitRequired,
Boolean useFSGitHandler,
Boolean keepWorkingDirChanges) {
Mono<Object> pageObjectMono;
try {
Mono<Boolean> 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 -> {

View File

@ -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,

View File

@ -80,7 +80,12 @@ public interface FileInterface {
Mono<Object> reconstructPackageJsonFromGitRepository(Path repoSuffix);
Mono<Object> 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 -

View File

@ -933,6 +933,9 @@ public class CommonGitFileUtilsCE {
String defaultArtifactId = gitArtifactMetadata.getDefaultArtifactId();
String refName = gitArtifactMetadata.getRefName();
String repoName = gitArtifactMetadata.getRepoName();
Mono<Boolean> useFSGitHandlerMono = featureFlagService.check(FeatureFlagEnum.release_git_api_contracts_enabled);
Mono<Boolean> 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<JSONObject> jsonObjectMono = fileUtils
.reconstructPageFromGitRepo(pageDTO.getName(), refName, baseRepoSuffix, isResetToLastCommitRequired)
Mono<JSONObject> 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 -> {