Skip to content

chore: FS layer has additional reset responsibility before reconstruction #39989

Merged
sondermanish merged 1 commit intoreleasefrom
chore/fs-layer
Mar 31, 2025
Merged

chore: FS layer has additional reset responsibility before reconstruction #39989
sondermanish merged 1 commit intoreleasefrom
chore/fs-layer

Conversation

@sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Mar 31, 2025

Description

This helps in resetting the file system to last commit in the following flows

  • Import
  • Checkout ref (Branch/tag)
  • pull
  • merge
  • discard

Fixes #39934

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/14176842029
Commit: a8202cb
Cypress dashboard.
Tags: @tag.Git
Spec:


Mon, 31 Mar 2025 17:39:11 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Introduced a repository reset option allowing users to revert to the latest commit on the current branch without needing to specify extra details.
    • Enhanced the artifact restoration process by applying this reset step to ensure a consistent repository state before rebuilding data.
  • Bug Fixes
    • Updated error notifications during reference creation for improved clarity.

@sondermanish sondermanish requested a review from a team as a code owner March 31, 2025 16:45
@sondermanish sondermanish requested a review from subrata71 March 31, 2025 16:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 31, 2025

Walkthrough

The pull request introduces a new public method resetToLastCommit(Path repoSuffix) in the Git handler implementation and its corresponding interface, allowing a reset to the last commit on the current branch without specifying a branch name. Additionally, the error message in the central Git service has been refined for correct grammar, and the artifact JSON reconstruction flow now calls this reset method before proceeding with JSON construction.

Changes

Files Change Summary
app/.../handler/ce/FSGitHandlerCEImpl.java
app/.../external/git/handler/FSGitHandler.java
Added a new resetToLastCommit(Path repoSuffix) method in both the implementation and the interface to allow a reset without providing a branch name. The existing overload with branchName remains unchanged.
app/.../central/CentralGitServiceCEImpl.java Updated the error message in the createReference method by removing an extra word, thereby correcting its grammatical structure.
app/.../git/fs/GitFSServiceCEImpl.java Modified the reconstructArtifactJsonFromGitRepository method to first obtain the repository suffix and then call resetToLastCommit(repoSuffix) before proceeding with artifact JSON reconstruction.

Sequence Diagram(s)

sequenceDiagram
    participant GitFS as GitFSServiceCEImpl
    participant FSGit as FSGitHandlerCEImpl
    participant Helper as GitArtifactHelper
    participant Common as CommonGitFileUtils

    GitFS->>Helper: Retrieve helper based on artifact type
    Helper-->>GitFS: Return helper & repoSuffix details
    GitFS->>FSGit: resetToLastCommit(repoSuffix)
    FSGit-->>GitFS: Return Mono<Boolean>
    GitFS->>Common: constructArtifactExchangeJsonFromGitRepositoryWithAnalytics(dto)
Loading

Assessment against linked issues

Objective Addressed Explanation
[Bug]: On deleting a page on a specific branch, the page gets deleted from all branches on import (#39934) The reset operation in artifact reconstruction may help isolate branch state, but its direct impact on the bug is unclear.

Possibly related PRs

Suggested labels

Bug, Medium, Git Product, Needs Triaging, ok-to-test, skip-changelog, Release Blocker, Packages & Git Pod

Suggested reviewers

  • subrata71
  • dvj1988

Poem

In the realm of code where branches align,
A reset is born to keep commits in line.
With a tweak in error messages, clear and bright,
The JSON flows anew in the Git service light.
Celebrate the change—our repository sings its tune!
🎉💻

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.31.1)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Bug Something isn't working Git Product Issues related to version control product High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage Packages & Git Pod All issues belonging to Packages and Git Production QA Needs QA attention Release Blocker This issue must be resolved before the release labels Mar 31, 2025
@sondermanish sondermanish requested a review from brayn003 March 31, 2025 16:46
@sondermanish sondermanish self-assigned this Mar 31, 2025
@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog and removed Bug Something isn't working labels Mar 31, 2025
@sondermanish sondermanish added the ok-to-test Required label for CI label Mar 31, 2025
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Mar 31, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java (1)

1417-1428: Fix typo in Javadoc and consider clarifying error handling.

  • The word "successfull" should be "successful" in the Javadoc.
  • Currently, errors are suppressed and return false. Consider clarifying in the doc or handling errors so the caller is aware of the failure details.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aaec892 and a8202cb.

📒 Files selected for processing (4)
  • app/server/appsmith-git/src/main/java/com/appsmith/git/handler/ce/FSGitHandlerCEImpl.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/handler/FSGitHandler.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: server-unit-tests / server-unit-tests
  • GitHub Check: server-spotless / spotless-check
🔇 Additional comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (2)

872-872: Grammar correction looks good

Fixing "is already exists" to "already exists" improves the error message clarity.


867-873: Improved Error Message Clarity in createReference Method
The error message has been updated to:
“either ref name already exists or it doesn't meet naming criteria, or the artifact is not in a publishable state”
This change corrects the grammatical error from the previous version and improves overall readability. Please verify that this message still accurately conveys the failure conditions in your ref creation workflow.

app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/handler/FSGitHandler.java (1)

206-211: New method signature adds important functionality

This new overloaded method allows resetting to the last commit on the current branch without needing to specify a branch name explicitly, which is useful for the artifact reconstruction flow mentioned in the PR description.

Comment on lines +278 to 290
GitArtifactHelper<?> gitArtifactHelper =
gitArtifactHelperResolver.getArtifactHelper(artifactJsonTransformationDTO.getArtifactType());

Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(
artifactJsonTransformationDTO.getWorkspaceId(),
artifactJsonTransformationDTO.getBaseArtifactId(),
artifactJsonTransformationDTO.getRepoName());

return fsGitHandler
.resetToLastCommit(repoSuffix)
.then(commonGitFileUtils.constructArtifactExchangeJsonFromGitRepositoryWithAnalytics(
artifactJsonTransformationDTO));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Handle possible reset failures.

resetToLastCommit(repoSuffix) may fail and return false. Consider explicitly handling or logging this result before proceeding to construct the artifact JSON to avoid potential inconsistencies.

@sondermanish sondermanish enabled auto-merge (squash) March 31, 2025 17:49
@sondermanish sondermanish merged commit a36d57b into release Mar 31, 2025
50 checks passed
@sondermanish sondermanish deleted the chore/fs-layer branch March 31, 2025 18:00
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
…tion (appsmithorg#39989)

## Description
### This helps in resetting the file system to last commit in the
following flows
- Import
- Checkout ref (Branch/tag)
- pull
- merge
- discard

Fixes appsmithorg#39934  


## Automation

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

### 🔍 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/14176842029>
> Commit: a8202cb
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14176842029&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Mon, 31 Mar 2025 17:39:11 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 repository reset option allowing users to revert to the
latest commit on the current branch without needing to specify extra
details.
- Enhanced the artifact restoration process by applying this reset step
to ensure a consistent repository state before rebuilding data.
- **Bug Fixes**
- Updated error notifications during reference creation for improved
clarity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Git Product Issues related to version control product High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git Production QA Needs QA attention Release Blocker This issue must be resolved before the release skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: On deleting a page on a specific branch in a git connected app, the page gets deleted from all branches on import

2 participants