chore: added reset before checkout ref (#40689)

## Description


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.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]
> 🟣 🟣 🟣 Your tests are running.
> Tests running at:
<https://github.com/appsmithorg/appsmith/actions/runs/15110572865>
> Commit: 4e470ffe6a65dfbbc1c0827664c2160e7ed6719f
> Workflow: `PR Automation test suite`
> Tags: `@tag.Git`
> Spec: ``
> <hr>Mon, 19 May 2025 10:26:43 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

- **Bug Fixes**
- Improved reliability of branch or tag checkout operations by ensuring
the repository is reset to the last commit before switching references.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Manish Kumar 2025-05-19 16:50:12 +05:30 committed by GitHub
parent acec5073c3
commit 43047b82f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -840,7 +840,9 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE {
jsonTransformationDTO.getRepoName());
// Tags and branch checkout with the same mechanism.
return fsGitHandler.checkoutToBranch(repoSuffix, jsonTransformationDTO.getRefName());
return fsGitHandler.resetToLastCommit(repoSuffix).flatMap(bool -> {
return fsGitHandler.checkoutToBranch(repoSuffix, jsonTransformationDTO.getRefName());
});
}
@Override