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: reference lifecycle #38174

Merged
merged 15 commits into from
Dec 17, 2024
Merged

chore: reference lifecycle #38174

merged 15 commits into from
Dec 17, 2024

Conversation

sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Dec 16, 2024

Description

Fixes #37451, #37455, #37448

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

Tip

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


Tue, 17 Dec 2024 11:05:27 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced new methods for handling Git references and statuses.
    • Added functionality to list branches and references, including options for remote checks.
    • New class GitRefDTO created to represent Git references.
    • New enumeration RefType defined to categorize reference types.
    • Enhanced Git operations with methods for checking out references and creating new branches.
  • Bug Fixes

    • Updated error handling and logging in Git status retrieval.
  • Chores

    • Deprecated the ORGANIZATION_ID constant and introduced REF_NAME.
    • Updated import statements for RefType across multiple classes.

@sondermanish sondermanish requested a review from a team as a code owner December 16, 2024 07:32
Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request introduces enhancements to Git-related services and constants in the Appsmith server codebase. The changes primarily focus on expanding Git reference handling capabilities, introducing new methods for branch and reference management, and updating constants. The modifications span multiple files across server and interface packages, introducing new DTOs, enums, and service methods to improve Git operation flexibility.

Changes

File Change Summary
FieldNameCE.java Added REF_TYPE and REF_NAME constants; deprecated ORGANIZATION_ID
CentralGitServiceCE.java Added checkoutReference and createReference methods
CentralGitServiceCEImpl.java Implemented new Git reference checkout methods, enhanced fetchRemoteChanges
GitHandlingServiceCE.java Added methods for listing branches/references, fetching changes, and getting status
GitFSServiceCEImpl.java Added methods for listing references, fetching changes, and repository status
GitRefDTO.java New DTO for representing Git references
RefType.java New enum for branch and tag reference types
GitArtifactMetadataCE.java Updated RefType import, added refType field
ArtifactJsonTransformationDTO.java Updated RefType import

Assessment against linked issues

Objective Addressed Explanation
Switch create branch method to super service [#37451] Partial implementation visible, but full context unclear

Possibly related PRs

Suggested reviewers

  • nidhi-nair

Poem

🌿 Git branches dance and sway,
Refactored code finds its way,
Constants whisper, methods sing,
A symphony of coding's wing!
🚀 Appsmith's magic takes its flight!

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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 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 changed the title Chore: checkout reference chore: checkout reference Dec 16, 2024
@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 16, 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: 2

🧹 Nitpick comments (5)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java (2)

38-40: Add JavaDoc comments for getStatus method

Including JavaDoc for the getStatus method would improve code readability and maintainability.


41-47: Document the checkoutReference method

Adding JavaDoc comments to checkoutReference will help clarify its purpose and usage.

app/server/appsmith-interfaces/src/main/java/com/appsmith/external/dtos/ce/GitStatusCE_DTO.java (1)

11-11: Address the TODO comment

Please resolve the TODO or create a follow-up task to ensure it doesn't get overlooked.

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

46-47: Include JavaDoc for listReferences

Adding documentation to the listReferences method would enhance understanding for future maintainers.


70-70: Add documentation for getStatus method

Providing JavaDoc comments for getStatus will improve code clarity and usability.

📜 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 376d3ba.

📒 Files selected for processing (6)
  • 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/constants/ce/FieldNameCE.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 (6 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/GitHandlingServiceCE.java (4 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java (3 hunks)
🔇 Additional comments (5)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (3)

339-359: Well-implemented checkoutReference method

The new checkoutReference method is correctly overloaded and includes proper input validation and error handling.


361-433: Efficient overload of checkoutReference

The protected overload of checkoutReference effectively reuses logic and maintains consistency.


1038-1167: Comprehensive implementation of getStatus methods

The getStatus methods are well-structured, with clear delegation and error handling. They enhance the Git operation capabilities effectively.

app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java (1)

105-105: LGTM!

The new constant follows the established naming patterns and is appropriately placed.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java (1)

Line range hint 282-647: Verify consistent Git command patterns

Let's verify that the new Git operations follow the same patterns as existing ones across the codebase.

Comment on lines 282 to 291
@Override
public Mono<List<String>> listReferences(
ArtifactJsonTransformationDTO artifactJsonTransformationDTO, RefType refType) {
if (RefType.BRANCH.equals(refType)) {
listBranches(artifactJsonTransformationDTO);
}

// TODO: include ref type for tags in fsGit Handler
return Mono.just(List.of());
}
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

Fix the branch listing implementation

The method has two critical issues:

  1. The listBranches result is not being returned (missing return)
  2. The method always returns an empty list regardless of the branch listing result

Apply this fix:

@Override
public Mono<List<String>> listReferences(
        ArtifactJsonTransformationDTO artifactJsonTransformationDTO, RefType refType) {
    if (RefType.BRANCH.equals(refType)) {
-        listBranches(artifactJsonTransformationDTO);
+        return listBranches(artifactJsonTransformationDTO);
    }

    // TODO: include ref type for tags in fsGit Handler
    return Mono.just(List.of());
}
📝 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<List<String>> listReferences(
ArtifactJsonTransformationDTO artifactJsonTransformationDTO, RefType refType) {
if (RefType.BRANCH.equals(refType)) {
listBranches(artifactJsonTransformationDTO);
}
// TODO: include ref type for tags in fsGit Handler
return Mono.just(List.of());
}
@Override
public Mono<List<String>> listReferences(
ArtifactJsonTransformationDTO artifactJsonTransformationDTO, RefType refType) {
if (RefType.BRANCH.equals(refType)) {
return listBranches(artifactJsonTransformationDTO);
}
// TODO: include ref type for tags in fsGit Handler
return Mono.just(List.of());
}

Comment on lines 634 to 647
@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 operations

The method should handle potential Git exceptions that could occur during status retrieval.

Apply this improvement:

@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 getting Git status: {}", error.getMessage());
+                return Mono.error(new AppsmithException(
+                        AppsmithError.GIT_ACTION_FAILED,
+                        "status",
+                        error.getMessage()));
+            });
}

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

Mono<GitStatusDTO> getStatus(
String branchedArtifactId, boolean compareRemote, ArtifactType artifactType, GitType gitType);

Mono<? extends Artifact> checkoutReference(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, should we not be able to make a DTO out of these params?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can!

Copy link
Contributor

Choose a reason for hiding this comment

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

Will you be replacing usage in a separate PR?

nidhi-nair
nidhi-nair previously approved these changes Dec 16, 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: 1

🧹 Nitpick comments (3)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/dtos/GitRefDTO.java (1)

8-11: Consider adding @builder annotation for flexible object creation.

The Lombok annotations are good, but adding @Builder would provide a more flexible way to create instances, especially useful when not all fields are required.

 @Data
 @AllArgsConstructor
 @NoArgsConstructor
+@Builder
 public class GitRefDTO {
app/server/appsmith-server/src/main/java/com/appsmith/server/git/dtos/ArtifactJsonTransformationDTO.java (1)

7-7: Address the TODO comment about DTO naming

The TODO indicates uncertainty about the DTO name. Consider renaming to GitArtifactTransformationDTO to better reflect its purpose.

app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/GitArtifactMetadataCE.java (1)

Line range hint 31-34: Track completion of transient field implementation

The TODO comments and @transient annotations indicate incomplete implementation. Consider creating tracking issues for:

  1. Making fields public
  2. Removing @transient annotations

Would you like me to create GitHub issues to track these implementation tasks?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 376d3ba and 804ed27.

📒 Files selected for processing (9)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/dtos/GitRefDTO.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/RefType.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/RefType.java (0 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/GitArtifactMetadataCE.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 (6 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/dtos/ArtifactJsonTransformationDTO.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java (5 hunks)
💤 Files with no reviewable changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/RefType.java
✅ Files skipped from review due to trivial changes (1)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/RefType.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java
👮 Files not reviewed due to content moderation or server errors (2)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java
🔇 Additional comments (6)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/dtos/GitRefDTO.java (2)

1-7: LGTM! Package structure and imports are well-organized.


1-20: Verify REST API usage and enum alignment.

Please verify:

  1. If this DTO will be used in REST endpoints, consider adding Jackson annotations
  2. Ensure RefType enum values cover all necessary Git reference types (branches, tags, remote refs)
✅ Verification successful

GitRefDTO implementation is appropriate for its usage context

The verification shows:

  1. GitRefDTO is only used internally in the service layer (CentralGitServiceCEImpl), not exposed via REST endpoints, so Jackson annotations aren't needed
  2. RefType enum correctly covers the essential Git reference types (BRANCH, TAG) which aligns with the DTO's usage in Git operations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if this DTO is used in REST controllers and if we need Jackson annotations
rg -l "GitRefDTO" | grep -i "controller"

# Verify RefType enum values
ast-grep --pattern 'enum RefType {
  $$$
}'

Length of output: 84


Script:

#!/bin/bash
# Search for GitRefDTO usage in all files
rg -l "GitRefDTO"

# Check if GitRefDTO is used in any REST-related context
rg "GitRefDTO" -A 5 -B 5

# Search for RefType enum definition
fd -e java -e kt -x rg -l "enum.*RefType"

# If found, show the enum content
fd -e java -e kt -x rg "enum.*RefType" -A 10

Length of output: 4284

app/server/appsmith-server/src/main/java/com/appsmith/server/git/dtos/ArtifactJsonTransformationDTO.java (1)

3-3: LGTM! Import change aligns with external Git types

The RefType import change is appropriate as it moves towards using common Git types from the external package.

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

71-72: Verify impact of isFetchAll parameter

The new isFetchAll parameter in fetchRemoteChanges could significantly impact performance with large repositories.


44-45: Consider adding validation for remote branch operations

The new branch and reference listing methods should include error handling for network failures and invalid remote states.

Also applies to: 49-52

app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/GitArtifactMetadataCE.java (1)

Line range hint 109-110: Clarify TODO comment intention

The TODO comment about restricting access needs clarification. Consider:

  1. What specific access restrictions are needed?
  2. When will the migration be performed?

Comment on lines +13 to +19
String refName;

RefType refType;

boolean isDefault;

boolean createdFromLocal;
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 field validation and documentation.

The fields would benefit from:

  1. Validation annotations for refName
  2. JavaDoc documentation explaining each field's purpose
  3. Making fields final for immutability
+import javax.validation.constraints.NotNull;
+
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
 public class GitRefDTO {
 
+    /** The name of the Git reference (e.g., branch name or tag name) */
+    @NotNull
-    String refName;
+    private final String refName;
 
+    /** The type of the Git reference (BRANCH or TAG) */
+    @NotNull
-    RefType refType;
+    private final RefType refType;
 
+    /** Indicates if this is the default reference (e.g., default branch) */
-    boolean isDefault;
+    private final boolean isDefault;
 
+    /** Indicates if the reference was created in the local repository */
-    boolean createdFromLocal;
+    private final boolean createdFromLocal;

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

@sondermanish sondermanish added the ok-to-test Required label for CI label Dec 16, 2024
@sondermanish sondermanish self-assigned this Dec 16, 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: 2

🧹 Nitpick comments (6)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (6)

349-351: Refactor duplicated null checks for referenceToBeCheckedOut

The null check for referenceToBeCheckedOut is duplicated in both methods. Consider refactoring to eliminate code duplication.

Also applies to: 369-371


413-416: Clarify error message for existing local reference

The error message can be clearer. Suggest rephrasing to: "Reference '" + referenceToBeCheckedOut + "' already exists locally as '" + finalRefName + "'."


419-419: Address the TODO: Refactor method to account for RefName

Please address the TODO comment to refactor the method and include RefName handling.

Would you like assistance with this refactor?


486-486: Include refType in error messages

Update the error handling to include refType for better clarity.


525-525: Address the TODO: Add refType support

Please implement refType support as indicated by the TODO comment.

Would you like assistance in adding this support?


538-538: Refine error handling strategy

Consider refactoring to handle this error in the appropriate layer, as suggested by the TODO.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 804ed27 and 5cf5026.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (4 hunks)
🔇 Additional comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (1)

553-554: Review use of doOnSuccess for state changes

Using doOnSuccess to call discardChanges may cause unintended side effects. Verify if flatMap is more appropriate for this operation.

GitConstants.GitCommandConstants.CREATE_BRANCH,
FALSE);
Mono<String> fetchRemoteMono =
gitHandlingService.fetchRemoteChanges(jsonTransformationDTO, baseGitAuth, TRUE);
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

Update fetchRemoteChanges calls to match new method signature

The fetchRemoteChanges method signature has changed. Update the calls at lines 498 and 1334 to match the new parameters, preventing compilation errors.

Example correction:

- gitHandlingService.fetchRemoteChanges(jsonTransformationDTO, baseGitAuth, TRUE);
+ gitHandlingService.fetchRemoteChanges(baseArtifact, refArtifact, TRUE, gitType, refType);

Also applies to: 1334-1335

GitRefDTO refDTO,
ArtifactType artifactType,
GitType gitType,
RefType refType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we sending ref type separately here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can put it in the DTO itself, right.

Copy link

Failed server tests

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

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 (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (2)

491-492: Add RefType in error message.

The TODO comment indicates missing RefType in error message which could make debugging harder.

Consider updating the error message to include RefType:

-                                new AppsmithException(
-                                        AppsmithError.INVALID_GIT_CONFIGURATION,
-                                        "Unable to find the parent reference. Please create a reference from other available references"));
+                                new AppsmithException(
+                                        AppsmithError.INVALID_GIT_CONFIGURATION,
+                                        "Unable to find the parent reference of type " + refType + ". Please create a reference from other available references"));

542-543: Consider moving error handling to handling layer.

The TODO comment suggests moving error handling to a dedicated layer for better separation of concerns.

Consider creating a dedicated error handling service/layer for Git operations to maintain consistency across the codebase.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5cf5026 and 03a3843.

📒 Files selected for processing (3)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.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 (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java
🔇 Additional comments (4)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCE.java (2)

42-48: LGTM! Well-structured method signature.

The method signature is comprehensive and follows reactive programming patterns with Mono return type.


50-51: LGTM! Clean method signature using DTO pattern.

The method signature appropriately uses GitRefDTO to encapsulate reference details.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/central/CentralGitServiceCEImpl.java (2)

110-111: LGTM! Well-defined constants.

Constants are appropriately named and scoped for Git reference handling.


1339-1340: LGTM! Proper method call with updated parameters.

The fetchRemoteChanges call correctly uses the new parameter structure.

Comment on lines +439 to +442
// TODO @Manish: add checkout Remote Branch
protected Mono<? extends Artifact> checkoutRemoteBranch(Artifact baseArtifact, String finalRefName) {
return null;
}
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

Implement the checkoutRemoteBranch method.

The method is currently returning null which could lead to NullPointerException when checking out remote branches.

Would you like me to help implement this method or create a GitHub issue to track this task?

@sondermanish sondermanish changed the title chore: checkout reference chore: reference lifecycle Dec 17, 2024
@nidhi-nair nidhi-nair merged commit 3f9b139 into release Dec 17, 2024
45 checks passed
@nidhi-nair nidhi-nair deleted the chore/references branch December 17, 2024 10:45
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 create branch method to super service
2 participants