Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added status changes #38170

Merged
merged 9 commits into from
Dec 17, 2024
Merged

chore: added status changes #38170

merged 9 commits into from
Dec 17, 2024

Conversation

sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Dec 14, 2024

Description

  • Central Git status implementation

Fixes #37441

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

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12367777643
Commit: 73a48ae
Cypress dashboard.
Tags: @tag.Git
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Sanity/Datasources/RestApiOAuth2Validation_spec.ts
List of identified flaky tests.
Tue, 17 Dec 2024 07:58:26 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new class to track the status of local Git repositories.
    • Added methods to retrieve Git status, including comparisons with remote repositories.
    • Enhanced Git service functionality with improved status management and error handling.
  • Bug Fixes

    • Improved file lock management during remote fetch operations.
  • Documentation

    • Added TODO comments for method naming improvements.

@sondermanish sondermanish self-assigned this Dec 14, 2024
@sondermanish sondermanish requested a review from a team as a code owner December 14, 2024 19:18
Copy link
Contributor

coderabbitai bot commented Dec 14, 2024

Warning

Rate limit exceeded

@sondermanish has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 21933b8 and f5dcc3f.

📒 Files selected for processing (1)
  • app/server/.run/ServerApplication.run.xml (1 hunks)

Walkthrough

This pull request introduces modifications to the Git-related services and configurations in the Appsmith server application. Key changes include updating the Java Runtime Environment configuration for the ServerApplication, adding a new Data Transfer Object (DTO) for Git status tracking, and enhancing methods within the Git service to improve status retrieval capabilities across various components.

Changes

File Change Summary
app/server/.run/ServerApplication.run.xml Updated ALTERNATIVE_JRE_PATH from temurin-17 to temurin-17"
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/dtos/ce/GitStatusCE_DTO.java New DTO class for tracking Git repository status with comprehensive tracking sets
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java Added getStatus method to retrieve Git status
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java Enhanced Git status retrieval methods with new implementation details
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java Added new getStatus method and annotated existing method with TODO
app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java Implemented getStatus method for file system Git operations

Possibly related PRs

Suggested Labels

Enhancement, Bug, Git Product, Task, ok-to-test, Packages & Git Pod

Suggested Reviewers

  • nidhi-nair
  • sharat87

Poem

🌿 Git's whispers, code's new dance,
Paths reconfigured with a glance,
Status tracked, runtime refined,
In bytes and branches intertwined,
A symphony of dev's advance! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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 the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Dec 14, 2024
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: 3

🧹 Outside diff range and nitpick comments (6)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (1)

946-954: Update Javadoc to reflect the correct return type

The Javadoc mentions that the method returns a Map, but it actually returns a Mono<GitStatusDTO>. Update the documentation for accuracy.

Suggested fix:

- * @return Map of json file names which are added, modified, conflicting, removed and the working tree if this is clean
+ * @return Mono of GitStatusDTO containing the Git status information
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java (1)

38-39: Add Javadoc for the new getStatus method

Include Javadoc comments to improve readability and maintainability.

Suggested addition:

/**
 * Retrieves the Git status for the specified branched artifact.
 *
 * @param branchedArtifactId the ID of the branched artifact
 * @param compareRemote whether to compare with the remote repository
 * @param artifactType the type of the artifact
 * @param gitType the type of the Git service
 * @return Mono emitting GitStatusDTO containing the status information
 */
Mono<GitStatusDTO> getStatus(
    String branchedArtifactId, boolean compareRemote, ArtifactType artifactType, GitType gitType);
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/dtos/ce/GitStatusCE_DTO.java (3)

11-11: Address the TODO comment

Please resolve or remove the TODO comment to maintain code clarity.


Line range hint 14-79: Declare class fields as private

To encapsulate the data properly, declare the class fields as private.

Suggested change:

- Set<String> modified;
+ private Set<String> modified;

- Set<String> added;
+ private Set<String> added;

- // ... and so on for all fields

Apply this change to all fields in the class.


Line range hint 57-73: Use Javadoc @deprecated tags for deprecated fields

To provide more context, add Javadoc @deprecated annotations alongside the @Deprecated annotation.

Suggested addition:

/**
 * @deprecated Use the detailed sets of modified resources instead.
 */
@Deprecated
private int modifiedJSLibs;

Apply this to all deprecated fields.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java (1)

55-57: Address the TODO comment for method naming

The TODO comment indicates that this method needs a proper name. Consider renaming it to better reflect its purpose, such as stageChangesForCommit or prepareGitChanges.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e2916b2 and 9e090e7.

📒 Files selected for processing (6)
  • app/server/.run/ServerApplication.run.xml (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/dtos/ce/GitStatusCE_DTO.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (4 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java (2 hunks)
🔇 Additional comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (2)

962-963: Handle potential null values from getBaseAndBranchedArtifacts

Ensure that the returned artifacts are not null to prevent possible NullPointerException.


990-992: ⚠️ Potential issue

Check for null branchName in branchedGitMetadata

branchedGitMetadata.getBranchName() may return null. Add a null check before proceeding.

Suggested fix:

         final String finalBranchName = branchedGitMetadata.getBranchName();
+        if (!StringUtils.hasText(finalBranchName)) {
+            return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.BRANCH_NAME));
+        }

Likely invalid or redundant comment.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java (1)

67-67: LGTM! Clean method signature addition

The new getStatus method follows the established pattern of the interface, using Mono for reactive processing and accepting the standard ArtifactJsonTransformationDTO parameter.

Comment on lines +987 to +988
branchedGitMetadata.setGitAuth(baseGitMetadata.getGitAuth());

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure branchedGitMetadata is not null before usage

There is a potential NullPointerException if branchedGitMetadata is null. Add a null check before setting gitAuth.

Suggested fix:

+        if (branchedGitMetadata == null) {
+            return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION, GIT_CONFIG_ERROR));
+        }
         branchedGitMetadata.setGitAuth(baseGitMetadata.getGitAuth());

Committable suggestion skipped: line range outside the PR's diff.

@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ServerApplication" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="ALTERNATIVE_JRE_PATH" value="temurin-17" />
<option name="ALTERNATIVE_JRE_PATH" value="/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home" />
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

Avoid hardcoding absolute JRE paths

Hardcoding the JRE path can lead to issues on different development environments. Consider using a relative path or environment variable.

Comment on lines +622 to +635
@Override
public Mono<GitStatusDTO> getStatus(ArtifactJsonTransformationDTO jsonTransformationDTO) {
String workspaceId = jsonTransformationDTO.getWorkspaceId();
String baseArtifactId = jsonTransformationDTO.getBaseArtifactId();
String repoName = jsonTransformationDTO.getRepoName();
String refName = jsonTransformationDTO.getRefName();

ArtifactType artifactType = jsonTransformationDTO.getArtifactType();
GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(workspaceId, baseArtifactId, repoName);

Path repoPath = fsGitHandler.createRepoPath(repoSuffix);
return fsGitHandler.getStatus(repoPath, refName);
}
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

Add error handling for Git status operations

While the implementation is clean, it should include error handling for potential Git operation failures, similar to other methods in the class.

Consider wrapping the Git status operation with error handling:

 @Override
 public Mono<GitStatusDTO> getStatus(ArtifactJsonTransformationDTO jsonTransformationDTO) {
     String workspaceId = jsonTransformationDTO.getWorkspaceId();
     String baseArtifactId = jsonTransformationDTO.getBaseArtifactId();
     String repoName = jsonTransformationDTO.getRepoName();
     String refName = jsonTransformationDTO.getRefName();

     ArtifactType artifactType = jsonTransformationDTO.getArtifactType();
     GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
     Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(workspaceId, baseArtifactId, repoName);

     Path repoPath = fsGitHandler.createRepoPath(repoSuffix);
-    return fsGitHandler.getStatus(repoPath, refName);
+    return fsGitHandler.getStatus(repoPath, refName)
+            .onErrorResume(error -> {
+                log.error("Error while fetching git status: {}", error.getMessage());
+                return Mono.error(new AppsmithException(
+                        AppsmithError.GIT_ACTION_FAILED,
+                        "status",
+                        error.getMessage()));
+            });
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Override
public Mono<GitStatusDTO> getStatus(ArtifactJsonTransformationDTO jsonTransformationDTO) {
String workspaceId = jsonTransformationDTO.getWorkspaceId();
String baseArtifactId = jsonTransformationDTO.getBaseArtifactId();
String repoName = jsonTransformationDTO.getRepoName();
String refName = jsonTransformationDTO.getRefName();
ArtifactType artifactType = jsonTransformationDTO.getArtifactType();
GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(workspaceId, baseArtifactId, repoName);
Path repoPath = fsGitHandler.createRepoPath(repoSuffix);
return fsGitHandler.getStatus(repoPath, refName);
}
@Override
public Mono<GitStatusDTO> getStatus(ArtifactJsonTransformationDTO jsonTransformationDTO) {
String workspaceId = jsonTransformationDTO.getWorkspaceId();
String baseArtifactId = jsonTransformationDTO.getBaseArtifactId();
String repoName = jsonTransformationDTO.getRepoName();
String refName = jsonTransformationDTO.getRefName();
ArtifactType artifactType = jsonTransformationDTO.getArtifactType();
GitArtifactHelper<?> gitArtifactHelper = gitArtifactHelperResolver.getArtifactHelper(artifactType);
Path repoSuffix = gitArtifactHelper.getRepoSuffixPath(workspaceId, baseArtifactId, repoName);
Path repoPath = fsGitHandler.createRepoPath(repoSuffix);
return fsGitHandler.getStatus(repoPath, refName)
.onErrorResume(error -> {
log.error("Error while fetching git status: {}", error.getMessage());
return Mono.error(new AppsmithException(
AppsmithError.GIT_ACTION_FAILED,
"status",
error.getMessage()));
});
}

Copy link

Failed server tests

  • com.appsmith.server.git.ServerSchemaMigrationEnforcerTest#saveGitRepo_ImportAndThenExport_diffOccurs

nidhi-nair
nidhi-nair previously approved these changes Dec 16, 2024
@sondermanish sondermanish added the ok-to-test Required label for CI label Dec 16, 2024
@github-actions github-actions bot added Git Product Issues related to version control product Packages & Git Pod All issues belonging to Packages and Git potential-duplicate This label marks issues that are potential duplicates of already open issues Task A simple Todo labels Dec 16, 2024
@sondermanish sondermanish added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Dec 17, 2024
@nidhi-nair nidhi-nair merged commit 979acc9 into release Dec 17, 2024
75 of 79 checks passed
@nidhi-nair nidhi-nair deleted the chore/status branch December 17, 2024 08:32
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 ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git potential-duplicate This label marks issues that are potential duplicates of already open issues skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Switch git status method to super service
2 participants