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: git mod - migrating apis for git #37984

Merged
merged 5 commits into from
Dec 6, 2024
Merged

chore: git mod - migrating apis for git #37984

merged 5 commits into from
Dec 6, 2024

Conversation

brayn003
Copy link
Contributor

@brayn003 brayn003 commented Dec 5, 2024

Description

  • Add application apis for git package

Fixes #37823

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/12194637717
Commit: e72e02f
Cypress dashboard.
Tags: @tag.Git
Spec:


Fri, 06 Dec 2024 08:23:16 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Introduced various asynchronous functions for Git operations, including:
      • checkoutBranchRequest
      • commitRequest
      • connectRequest
      • createBranchRequest
      • deleteBranchRequest
      • fetchBranchesRequest
      • fetchGitMetadataRequest
      • fetchProtectedBranchesRequest
      • mergeRequest
      • pullRequest
      • toggleAutocommitRequest
      • triggerAutocommitRequest
      • updateGlobalConfigRequest
      • updateLocalConfigRequest
      • updateProtectedBranchesRequest
    • Added new enumeration AutocommitStatus and interfaces to enhance type safety for Git operations.
  • Bug Fixes
    • Updated import paths for consistency and clarity across multiple files.
  • Documentation
    • Enhanced type definitions for various request and response structures.

@brayn003 brayn003 self-assigned this Dec 5, 2024
Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

This pull request introduces several new asynchronous functions related to Git operations, including branch management, commit requests, and configuration updates. Additionally, it adds new TypeScript interfaces for request parameters and response structures, enhancing type safety. A new enumeration, AutocommitStatus, is also introduced to categorize the status of autocommit operations. Import paths for certain types have been updated to reflect a new module structure, ensuring that the codebase remains organized and maintainable.

Changes

File Path Change Summary
app/client/src/git/constants/enums.ts Added new enum AutocommitStatus with values: IN_PROGRESS, LOCKED, PUBLISHED, IDLE, NOT_REQUIRED, NON_GIT_APP.
app/client/src/git/requests/checkoutBranchRequest.ts Introduced checkoutBranchRequest function for checking out branches.
app/client/src/git/requests/checkoutBranchRequest.types.ts Added interfaces: CheckoutBranchRequestParams and CheckoutBranchResponse.
app/client/src/git/requests/commitRequest.ts Introduced commitRequest function for committing changes.
app/client/src/git/requests/commitRequest.types.ts Added interfaces: CommitRequestParams and CommitResponse.
app/client/src/git/requests/connectRequest.ts Introduced connectRequest function for connecting applications.
app/client/src/git/requests/connectRequest.types.ts Added interfaces: ConnectRequestParams and ConnectResponse.
app/client/src/git/requests/constants.ts Added constant GIT_BASE_URL set to "/v1/git".
app/client/src/git/requests/createBranchRequest.ts Introduced createBranchRequest function for creating branches.
app/client/src/git/requests/createBranchRequest.types.ts Added interfaces: CreateBranchRequestParams and CreateBranchResponse.
app/client/src/git/requests/deleteBranchRequest.ts Introduced deleteBranchRequest function for deleting branches.
app/client/src/git/requests/deleteBranchRequest.types.ts Added interfaces: DeleteBranchRequestParams and DeleteBranchResponse.
app/client/src/git/requests/discardRequest.ts Introduced discardRequest function for discarding changes.
app/client/src/git/requests/disconnectRequest.ts Introduced disconnectRequest function for disconnecting applications.
app/client/src/git/requests/disconnectRequest.types.ts Added interface: DisconnectResponse.
app/client/src/git/requests/fetchAutocommitProgressRequest.ts Introduced fetchAutocommitProgressRequest function for fetching autocommit progress.
app/client/src/git/requests/fetchAutocommitProgressRequest.types.ts Added interface: FetchAutocommitProgressResponse.
app/client/src/git/requests/fetchBranchesRequest.ts Introduced fetchBranchesRequest function for fetching branches.
app/client/src/git/requests/fetchBranchesRequest.types.ts Added interfaces: FetchBranchesRequestParams, SingleBranch, and type alias FetchBranchesResponse.
app/client/src/git/requests/fetchGitMetadataRequest.ts Introduced fetchGitMetadataRequest function for fetching Git metadata.
app/client/src/git/requests/fetchGitMetadataRequest.types.ts Added interface: FetchGitMetadataResponse.
app/client/src/git/requests/fetchGlobalConfigRequest.ts Introduced fetchGlobalConfigRequest function for fetching global configuration.
app/client/src/git/requests/fetchGlobalConfigRequest.types.ts Added interface: FetchGlobalConfigResponse.
app/client/src/git/requests/fetchLocalConfigRequest.ts Introduced fetchLocalConfigRequest function for fetching local configuration.
app/client/src/git/requests/fetchLocalConfigRequest.types.ts Added interface: FetchLocalConfigResponse.
app/client/src/git/requests/fetchMergeStatusRequest.ts Introduced fetchMergeStatusRequest function for fetching merge status.
app/client/src/git/requests/fetchMergeStatusRequest.types.ts Added interfaces: FetchMergeStatusRequestParams and FetchMergeStatusResponse.
app/client/src/git/requests/fetchProtectedBranchesRequest.ts Introduced fetchProtectedBranchesRequest function for fetching protected branches.
app/client/src/git/requests/fetchProtectedBranchesRequest.types.ts Added type alias: FetchProtectedBranches.
app/client/src/git/requests/fetchSSHKeyRequest.ts Introduced fetchSSHKeyRequest function for fetching SSH keys.
app/client/src/git/requests/fetchSSHKeyRequest.types.ts Added interface: FetchSSHKeyResponse.
app/client/src/git/requests/fetchStatusRequest.ts Introduced fetchStatusRequest function for fetching status.
app/client/src/git/requests/fetchStatusRequest.types.ts Added interfaces: FetchStatusRequestParams and FetchStatusResponse.
app/client/src/git/requests/generateSSHKeyRequest.ts Introduced generateSSHKeyRequest function for generating SSH keys.
app/client/src/git/requests/generateSSHKeyRequest.types.ts Added interfaces: GenerateSSHKeyRequestParams and GenerateSSHKeyResponse.
app/client/src/git/requests/importGitRequest.ts Introduced importGitRequest function for importing Git repositories.
app/client/src/git/requests/importGitRequest.types.ts Added interfaces: ImportGitRequestParams and ImportGitResponse.
app/client/src/git/requests/mergeRequest.ts Introduced mergeRequest function for merging branches.
app/client/src/git/requests/mergeRequest.types.ts Added interfaces: MergeRequestParams and MergeResponse.
app/client/src/git/requests/pullRequest.ts Introduced pullRequest function for retrieving pull request data.
app/client/src/git/requests/pullRequest.types.ts Added interface: PullRequestResponse.
app/client/src/git/requests/toggleAutocommitRequest.ts Introduced toggleAutocommitRequest function for toggling autocommit.
app/client/src/git/requests/toggleAutocommitRequest.types.ts Added type alias: ToggleAutocommitResponse.
app/client/src/git/requests/triggerAutocommitRequest.ts Introduced triggerAutocommitRequest function for triggering autocommit.
app/client/src/git/requests/triggerAutocommitRequest.types.ts Added interface: TriggerAutocommitResponse.
app/client/src/git/requests/updateGlobalConfigRequest.ts Introduced updateGlobalConfigRequest function for updating global configuration.
app/client/src/git/requests/updateGlobalConfigRequest.types.ts Added interfaces: UpdateGlobalConfigRequestParams and UpdateGlobalConfigResponse.
app/client/src/git/requests/updateLocalConfigRequest.ts Introduced updateLocalConfigRequest function for updating local configuration.
app/client/src/git/requests/updateLocalConfigRequest.types.ts Added interfaces: UpdateLocalConfigRequestParams and UpdateLocalConfigResponse.
app/client/src/git/requests/updateProtectedBranchesRequest.ts Introduced updateProtectedBranchesRequest function for updating protected branches.
app/client/src/git/requests/updateProtectedBranchesRequest.types.ts Added interfaces: UpdateProtectedBranchesRequestParams and type alias UpdateProtectedBranchesResponse.
app/client/src/git/types.ts Updated import path for types from ./enums to ./constants/enums.

Possibly related PRs

Suggested labels

Enhancement, Git Product, Git Platform Pod

Suggested reviewers

  • sharat87
  • sagar-qa007

"In code we trust, with enums anew,
Functions and types, a clearer view.
From branches to commits, our Git takes flight,
With every request, our future is bright!
So let’s merge and commit, with joy we deploy,
For every change made, brings us closer to joy!" 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 146238c and e72e02f.

📒 Files selected for processing (25)
  • app/client/src/git/requests/checkoutBranchRequest.ts (1 hunks)
  • app/client/src/git/requests/commitRequest.ts (1 hunks)
  • app/client/src/git/requests/connectRequest.ts (1 hunks)
  • app/client/src/git/requests/createBranchRequest.ts (1 hunks)
  • app/client/src/git/requests/deleteBranchRequest.ts (1 hunks)
  • app/client/src/git/requests/discardRequest.ts (1 hunks)
  • app/client/src/git/requests/disconnectRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchAutocommitProgressRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchBranchesRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchGitMetadataRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchGlobalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchLocalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchMergeStatusRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchProtectedBranchesRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchSSHKeyRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchStatusRequest.ts (1 hunks)
  • app/client/src/git/requests/generateSSHKeyRequest.ts (1 hunks)
  • app/client/src/git/requests/importGitRequest.ts (1 hunks)
  • app/client/src/git/requests/mergeRequest.ts (1 hunks)
  • app/client/src/git/requests/pullRequest.ts (1 hunks)
  • app/client/src/git/requests/toggleAutocommitRequest.ts (1 hunks)
  • app/client/src/git/requests/triggerAutocommitRequest.ts (1 hunks)
  • app/client/src/git/requests/updateGlobalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/updateLocalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/updateProtectedBranchesRequest.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (25)
  • app/client/src/git/requests/fetchLocalConfigRequest.ts
  • app/client/src/git/requests/discardRequest.ts
  • app/client/src/git/requests/updateGlobalConfigRequest.ts
  • app/client/src/git/requests/fetchSSHKeyRequest.ts
  • app/client/src/git/requests/fetchGitMetadataRequest.ts
  • app/client/src/git/requests/fetchMergeStatusRequest.ts
  • app/client/src/git/requests/pullRequest.ts
  • app/client/src/git/requests/disconnectRequest.ts
  • app/client/src/git/requests/deleteBranchRequest.ts
  • app/client/src/git/requests/commitRequest.ts
  • app/client/src/git/requests/updateProtectedBranchesRequest.ts
  • app/client/src/git/requests/fetchAutocommitProgressRequest.ts
  • app/client/src/git/requests/fetchProtectedBranchesRequest.ts
  • app/client/src/git/requests/fetchGlobalConfigRequest.ts
  • app/client/src/git/requests/importGitRequest.ts
  • app/client/src/git/requests/toggleAutocommitRequest.ts
  • app/client/src/git/requests/triggerAutocommitRequest.ts
  • app/client/src/git/requests/mergeRequest.ts
  • app/client/src/git/requests/createBranchRequest.ts
  • app/client/src/git/requests/connectRequest.ts
  • app/client/src/git/requests/fetchStatusRequest.ts
  • app/client/src/git/requests/fetchBranchesRequest.ts
  • app/client/src/git/requests/updateLocalConfigRequest.ts
  • app/client/src/git/requests/checkoutBranchRequest.ts
  • app/client/src/git/requests/generateSSHKeyRequest.ts

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 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 Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod Task A simple Todo labels Dec 5, 2024
@brayn003 brayn003 added ok-to-test Required label for CI and removed Task A simple Todo Packages Pod issues that belong to the packages pod Packages & Git Pod All issues belonging to Packages and Git labels Dec 5, 2024
@github-actions github-actions bot added Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod Task A simple Todo skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Dec 5, 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: 25

🧹 Outside diff range and nitpick comments (39)
app/client/src/git/requests/toggleAutocommitRequest.ts (2)

6-12: Add JSDoc documentation for the function.

The implementation looks good, but adding documentation would help explain the purpose and behavior of this toggle functionality.

Add documentation like this:

+/**
+ * Toggles the auto-commit feature for a specific application.
+ * @param baseApplicationId - The ID of the application to toggle auto-commit for
+ * @returns A promise that resolves to a boolean indicating the new auto-commit state
+ * @throws {AxiosError} When the request fails
+ */
 export async function toggleAutocommitRequest(
   baseApplicationId: string,
 ): Promise<AxiosResponse<ToggleAutocommitResponse>> {

6-12: Consider adding specific error handling types.

While the implementation is correct, consider defining specific error types for better error handling by consumers.

Add error types like this:

export interface ToggleAutocommitError {
  message: string;
  code: 'INVALID_APP_ID' | 'PERMISSION_DENIED' | 'GIT_NOT_CONNECTED';
}

Then update the return type:

Promise<AxiosResponse<ToggleAutocommitResponse, ToggleAutocommitError>>
app/client/src/git/requests/deleteBranchRequest.types.ts (2)

1-3: LGTM! Consider adding validation for branch name.

The interface is clean and focused. Consider adding JSDoc comments to document any branch naming constraints.

 export interface DeleteBranchRequestParams {
+  /** Name of the branch to delete. Should follow git branch naming conventions. */
   branchName: string;
 }

5-8: Consider using more descriptive property names.

While the comments clarify the purpose, consider using more descriptive property names to improve code readability.

 export interface DeleteBranchResponse {
-  id: string; // applicationId
-  baseId: string; // baseApplicationId
+  applicationId: string;
+  baseApplicationId: string;
 }
app/client/src/git/requests/deleteBranchRequest.ts (1)

9-12: Consider adding input validation.

The function should validate the baseApplicationId and branch name before making the API call.

if (!baseApplicationId?.trim()) {
  throw new Error("baseApplicationId is required");
}
if (!params.branchName?.trim()) {
  throw new Error("branchName is required");
}
app/client/src/git/requests/fetchSSHKeyRequest.types.ts (1)

1-6: Consider clarifying or consolidating regenerated key properties

The interface has two similar-looking boolean properties: isRegeneratedKey and regeneratedKey. These might cause confusion for consumers of this API.

Consider either:

  1. Consolidating into a single property, or
  2. Adding JSDoc comments to clarify the difference between these properties
 export interface FetchSSHKeyResponse {
   publicKey: string;
   docUrl: string;
+  /** Indicates if the key was regenerated in the current request */
   isRegeneratedKey: boolean;
+  /** Indicates if the key was previously regenerated */
   regeneratedKey: boolean;
 }
app/client/src/git/requests/updateGlobalConfigRequest.types.ts (2)

1-4: Consider adding email validation constraint

The authorEmail field could benefit from a string pattern constraint to ensure valid email formats.

export interface UpdateGlobalConfigRequestParams {
  authorName: string;
-  authorEmail: string;
+  authorEmail: string & { __brand: 'Email' }; // TypeScript branded type for email validation
}

6-11: Consider making response fields optional

Response fields should typically be marked as optional to handle partial responses gracefully.

export interface UpdateGlobalConfigResponse {
  default: {
-    authorName: string;
-    authorEmail: string;
+    authorName?: string;
+    authorEmail?: string;
  };
}
app/client/src/git/requests/pullRequest.ts (1)

1-4: Consider using path parameters utility

If you have a URL construction utility, consider using it instead of template literals for better maintainability.

app/client/src/git/requests/fetchMergeStatusRequest.types.ts (2)

7-8: Consider renaming isMergeAble to isMergeable

The property name should follow conventional camelCase spelling for better consistency.

-  isMergeAble: boolean;
+  isMergeable: boolean;

8-8: Enhance the status property documentation

Consider using a string literal type or enum to define possible status values instead of a generic string type with just a comment.

-  status: string; // merge status
+  status: 'MERGEABLE' | 'CONFLICTS' | 'ERROR';  // Define possible merge status values
app/client/src/git/requests/updateProtectedBranchesRequest.types.ts (2)

1-3: Add JSDoc documentation and consider branch name validation

The interface would benefit from documentation explaining its purpose and any constraints on branch names.

+/**
+ * Parameters for updating protected branches in a Git repository
+ * @property branchNames - Array of branch names to be protected
+ */
 export interface UpdateProtectedBranchesRequestParams {
+  /** Array of valid Git branch names */
   branchNames: string[];
 }

5-5: Add documentation for response type

The response type should include documentation explaining the returned array contents.

+/** Array of successfully protected branch names */
 export type UpdateProtectedBranchesResponse = string[];
app/client/src/git/requests/fetchBranchesRequest.types.ts (2)

1-3: LGTM! Consider adding JSDoc comments.

The interface is well-defined and properly exported. Adding JSDoc comments would improve developer experience.

+/**
+ * Parameters for fetching Git branches
+ * @property pruneBranches - When true, removes tracking branches that no longer exist on the remote
+ */
 export interface FetchBranchesRequestParams {
   pruneBranches: boolean;
 }

5-11: Consider making properties readonly for immutability.

The interface structure is good, but making properties readonly would prevent accidental mutations of response data.

 interface SingleBranch {
-  branchName: string;
-  createdFromLocal: string;
-  default: boolean;
+  readonly branchName: string;
+  readonly createdFromLocal: string;
+  readonly default: boolean;
 }
app/client/src/git/requests/createBranchRequest.types.ts (1)

5-8: Consider adding more descriptive JSDoc comments.

While the inline comments are helpful, consider using JSDoc format for better IDE integration and documentation.

 export interface CreateBranchResponse {
+  /** The ID of the newly created branch application */
   id: string; // applicationId
+  /** The ID of the original application this branch was created from */
   baseId: string; // baseApplicationId
 }
app/client/src/git/requests/checkoutBranchRequest.types.ts (2)

1-3: Consider adding validation constraints for branchName

The interface looks good, but consider adding validation constraints or a regex pattern for valid Git branch names to prevent invalid branch checkouts.

+import { IsString, Matches } from 'class-validator';

 export interface CheckoutBranchRequestParams {
+  @IsString()
+  @Matches(/^[a-zA-Z0-9-_/.]+$/, {
+    message: 'Branch name can only contain letters, numbers, and the characters: - _ / .'
+  })
   branchName: string;
 }

5-8: Enhance documentation for response interface

The interface is well-structured, but the comments could be more descriptive.

 export interface CheckoutBranchResponse {
-  id: string; // applicationId
-  baseId: string; // baseApplicationId
+  id: string; // Current application ID after branch checkout
+  baseId: string; // Original application ID from which the branch was created
 }
app/client/src/git/requests/fetchProtectedBranchesRequest.ts (2)

6-10: Consider URL encoding the baseApplicationId parameter

The implementation looks good, but consider encoding the baseApplicationId to handle special characters safely.

-  return Api.get(`${GIT_BASE_URL}/branch/app/${baseApplicationId}/protected`);
+  return Api.get(`${GIT_BASE_URL}/branch/app/${encodeURIComponent(baseApplicationId)}/protected`);

6-8: Add JSDoc documentation for better API discoverability

Consider adding JSDoc documentation to describe the function's purpose, parameters, and return type.

+/**
+ * Fetches the list of protected branches for a given application
+ * @param baseApplicationId - The ID of the application to fetch protected branches for
+ * @returns Promise resolving to an array of protected branch names
+ */
 export async function fetchProtectedBranchesRequest(
   baseApplicationId: string,
 ): Promise<AxiosResponse<FetchProtectedBranches>> {
app/client/src/git/requests/fetchGlobalConfigRequest.types.ts (1)

1-4: Add JSDoc documentation for better API documentation.

Consider adding JSDoc documentation to describe the purpose and usage of this interface.

+/**
+ * Response interface for fetching global Git configuration.
+ * Contains author details used for Git commits.
+ */
 export interface FetchGlobalConfigResponse {
   authorName: string;
   authorEmail: string;
 }
app/client/src/git/requests/commitRequest.types.ts (2)

1-4: Add JSDoc documentation and consider input validation.

The interface would benefit from documentation and potentially runtime validation for the commit message.

+/**
+ * Parameters for making a Git commit request.
+ * @property commitMessage - The message to be used for the commit
+ * @property doPush - Whether to push the commit to remote after committing
+ */
 export interface CommitRequestParams {
   commitMessage: string;
   doPush: boolean;
 }

6-6: Consider a more specific response type.

Using a plain string type for CommitResponse might be too generic. Consider creating a more specific type that includes commit hash, timestamp, or status.

-export type CommitResponse = string;
+export interface CommitResponse {
+  commitHash: string;
+  timestamp: string;
+  status: 'success' | 'failure';
+}
app/client/src/git/requests/triggerAutocommitRequest.types.ts (1)

3-7: Consider adding JSDoc and constraining the progress type

The interface looks well-structured, but could benefit from documentation and type constraints.

+/** Response interface for auto-commit trigger operations */
 export interface TriggerAutocommitResponse {
+  /** Current status of the auto-commit operation */
   autoCommitResponse: AutocommitStatus;
+  /** Progress percentage of the operation (0-100) */
-  progress: number;
+  progress: 0 | 25 | 50 | 75 | 100;
+  /** Name of the branch where auto-commit is being performed */
   branchName: string;
 }
app/client/src/git/requests/updateLocalConfigRequest.types.ts (1)

1-5: Consider adding email validation and optional fields

The interface could benefit from stricter email validation and optional fields.

+import { z } from "zod";
+
+const emailSchema = z.string().email();
+
 export interface UpdateLocalConfigRequestParams {
   authorName: string;
-  authorEmail: string;
+  authorEmail: string & z.infer<typeof emailSchema>;
   useGlobalProfile: boolean;
 }
app/client/src/git/requests/fetchGlobalConfigRequest.ts (2)

6-10: Consider implementing response caching

Global config is likely accessed frequently. Consider implementing a caching strategy.

+const configCache = new Map<string, FetchGlobalConfigResponse>();
+const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
+
 export async function fetchGlobalConfigRequest(): Promise<
   AxiosResponse<FetchGlobalConfigResponse>
 > {
+  const cachedConfig = configCache.get('default');
+  if (cachedConfig) {
+    return Promise.resolve({ data: cachedConfig } as AxiosResponse<FetchGlobalConfigResponse>);
+  }
   return Api.get(`${GIT_BASE_URL}/profile/default`);
 }

1-4: Consider using a custom API client

For better error handling and request interceptors, consider using a custom API client for Git operations.

// Suggestion: Create a GitApiClient class
class GitApiClient extends Api {
  constructor() {
    super();
    this.interceptors.response.use(
      response => response,
      error => {
        // Handle Git-specific errors
        return Promise.reject(error);
      }
    );
  }
}
app/client/src/git/requests/fetchLocalConfigRequest.ts (1)

9-9: Consider adding error handling

The request could fail due to network issues or invalid application ID.

Consider wrapping the API call in a try-catch block and handling common error scenarios:

 export async function fetchLocalConfigRequest(
   baseApplicationId: string,
 ): Promise<AxiosResponse<FetchGlobalConfigResponse>> {
-  return Api.get(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`);
+  try {
+    return await Api.get(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`);
+  } catch (error) {
+    if (axios.isAxiosError(error)) {
+      // Handle specific error cases
+      throw new Error(`Failed to fetch git config: ${error.message}`);
+    }
+    throw error;
+  }
 }
app/client/src/git/requests/triggerAutocommitRequest.ts (1)

6-10: Add timeout handling for auto-commit operation

Auto-commit operations can be long-running and might need a timeout mechanism.

Consider adding a timeout configuration:

 export async function triggerAutocommitRequest(
   branchedApplicationId: string,
 ): Promise<AxiosResponse<TriggerAutocommitResponse>> {
-  return Api.post(`${GIT_BASE_URL}/auto-commit/app/${branchedApplicationId}`);
+  return Api.post(
+    `${GIT_BASE_URL}/auto-commit/app/${branchedApplicationId}`,
+    null,
+    { timeout: 30000 } // 30 second timeout
+  );
 }
app/client/src/git/requests/importGitRequest.ts (1)

1-14: Consider implementing request cancellation

For long-running Git import operations, it would be helpful to support cancellation.

Consider using AbortController:

 import Api from "api/Api";
 import { GIT_BASE_URL } from "./constants";
 import type {
   ImportGitRequestParams,
   ImportGitResponse,
 } from "./importGitRequest.types";
-import type { AxiosResponse } from "axios";
+import type { AxiosResponse, CancelToken } from "axios";

 export async function importGitRequest(
   workspaceId: string,
   params: ImportGitRequestParams,
+  cancelToken?: CancelToken
 ): Promise<AxiosResponse<ImportGitResponse>> {
-  return Api.post(`${GIT_BASE_URL}/import/${workspaceId}`, params);
+  return Api.post(`${GIT_BASE_URL}/import/${workspaceId}`, params, { cancelToken });
 }
app/client/src/git/requests/connectRequest.ts (1)

9-14: Consider adding error handling for connection failures

The implementation looks clean but should handle potential connection failures explicitly.

Consider wrapping the API call with try-catch:

 export async function connectRequest(
   baseApplicationId: string,
   params: ConnectRequestParams,
 ): Promise<AxiosResponse<ConnectResponse>> {
+  try {
     return Api.post(`${GIT_BASE_URL}/connect/app/${baseApplicationId}`, params);
+  } catch (error) {
+    throw new Error(`Git connection failed: ${error.message}`);
+  }
 }
app/client/src/git/requests/fetchStatusRequest.ts (1)

9-14: Consider enhancing error handling and timeout configuration

The implementation looks clean, but consider these improvements:

  1. Add specific error handling for common Git-related errors
  2. Configure request timeout for long-running Git operations
 export async function fetchStatusRequest(
   branchedApplicationId: string,
   params: FetchStatusRequestParams,
 ): Promise<AxiosResponse<FetchStatusResponse>> {
-  return Api.get(`${GIT_BASE_URL}/status/app/${branchedApplicationId}`, params);
+  return Api.get(
+    `${GIT_BASE_URL}/status/app/${branchedApplicationId}`,
+    params,
+    { timeout: 30000 } // 30s timeout for potentially slow Git operations
+  );
 }
app/client/src/git/requests/updateLocalConfigRequest.ts (1)

9-14: Add input validation for baseApplicationId

Consider adding validation for the baseApplicationId parameter to ensure it's not empty or malformed.

 export async function updateLocalConfigRequest(
   baseApplicationId: string,
   params: UpdateLocalConfigRequestParams,
 ): Promise<AxiosResponse<UpdateLocalConfigResponse>> {
+  if (!baseApplicationId?.trim()) {
+    throw new Error('Invalid baseApplicationId');
+  }
   return Api.put(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`, params);
 }
app/client/src/git/requests/connectRequest.types.ts (3)

20-20: Fix typo in property name

The property lastCommitedAt has a typo - it should be lastCommittedAt (two 't's).


1-8: Consider adding string pattern validations

The interface could benefit from string pattern validations for remoteUrl and authorEmail.

+type GitRemoteUrl = string & { readonly brand: unique symbol };
+type GitEmail = string & { readonly brand: unique symbol };

 export interface ConnectRequestParams {
-  remoteUrl: string;
+  remoteUrl: GitRemoteUrl;
   gitProfile?: {
     authorName: string;
-    authorEmail: string;
+    authorEmail: GitEmail;
     useDefaultProfile?: boolean;
   };
 }

10-24: Consider documenting the response interface fields

The ConnectResponse interface has many fields that would benefit from JSDoc comments explaining their purpose and possible values.

app/client/src/git/requests/importGitRequest.types.ts (1)

20-20: Fix typo in property name

The property lastCommitedAt has a typo. It should be lastCommittedAt.

app/client/src/git/constants/enums.ts (1)

29-36: Add JSDoc documentation for AutocommitStatus enum

Consider adding JSDoc documentation to describe each status and when they occur. This will help other developers understand the autocommit flow better.

+/**
+ * Represents the various states of an autocommit operation
+ * @enum {string}
+ */
 export enum AutocommitStatus {
+  /** Operation is currently in progress */
   IN_PROGRESS = "IN_PROGRESS",
+  /** Operation is locked and cannot proceed */
   LOCKED = "LOCKED",
+  /** Changes have been successfully published */
   PUBLISHED = "PUBLISHED",
+  /** System is idle and ready for next operation */
   IDLE = "IDLE",
+  /** Autocommit is not required in current context */
   NOT_REQUIRED = "NOT_REQUIRED",
+  /** Application is not Git-enabled */
   NON_GIT_APP = "NON_GIT_APP",
 }
app/client/src/git/requests/fetchStatusRequest.types.ts (1)

5-38: Consider reorganizing interface properties for better maintainability

The interface could benefit from logical grouping of related properties. Consider restructuring using nested interfaces:

interface GitStatusCounts {
  aheadCount: number;
  behindCount: number;
  modifiedDatasources: number;
  modifiedJSLibs: number;
  modifiedJSObjects: number;
  modifiedModuleInstances: number;
  modifiedModules: number;
  modifiedPages: number;
  modifiedQueries: number;
}

interface GitStatusChanges {
  added: string[];
  modified: string[];
  removed: string[];
  conflicting: string[];
}

interface ComponentChanges {
  datasources: GitStatusChanges;
  jsLibs: GitStatusChanges;
  jsObjects: GitStatusChanges;
  pages: GitStatusChanges;
  queries: GitStatusChanges;
}

export interface FetchStatusResponse {
  counts: GitStatusCounts;
  changes: ComponentChanges;
  remoteBranch: string;
  isClean: boolean;
  discardDocUrl: string;
  migrationMessage: string;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 80f2000 and 1119f65.

📒 Files selected for processing (52)
  • app/client/src/git/constants/enums.ts (1 hunks)
  • app/client/src/git/requests/checkoutBranchRequest.ts (1 hunks)
  • app/client/src/git/requests/checkoutBranchRequest.types.ts (1 hunks)
  • app/client/src/git/requests/commitRequest.ts (1 hunks)
  • app/client/src/git/requests/commitRequest.types.ts (1 hunks)
  • app/client/src/git/requests/connectRequest.ts (1 hunks)
  • app/client/src/git/requests/connectRequest.types.ts (1 hunks)
  • app/client/src/git/requests/constants.ts (1 hunks)
  • app/client/src/git/requests/createBranchRequest.ts (1 hunks)
  • app/client/src/git/requests/createBranchRequest.types.ts (1 hunks)
  • app/client/src/git/requests/deleteBranchRequest.ts (1 hunks)
  • app/client/src/git/requests/deleteBranchRequest.types.ts (1 hunks)
  • app/client/src/git/requests/discardRequest.ts (1 hunks)
  • app/client/src/git/requests/disconnectRequest.ts (1 hunks)
  • app/client/src/git/requests/disconnectRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchAutocommitProgressRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchAutocommitProgressRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchBranchesRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchBranchesRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchGitMetadataRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchGitMetadataRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchGlobalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchGlobalConfigRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchLocalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchLocalConfigRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchMergeStatusRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchMergeStatusRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchProtectedBranchesRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchProtectedBranchesRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchSSHKeyRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchSSHKeyRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchStatusRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchStatusRequest.types.ts (1 hunks)
  • app/client/src/git/requests/generateSSHKeyRequest.ts (1 hunks)
  • app/client/src/git/requests/generateSSHKeyRequest.types.ts (1 hunks)
  • app/client/src/git/requests/importGitRequest.ts (1 hunks)
  • app/client/src/git/requests/importGitRequest.types.ts (1 hunks)
  • app/client/src/git/requests/mergeRequest.ts (1 hunks)
  • app/client/src/git/requests/mergeRequest.types.ts (1 hunks)
  • app/client/src/git/requests/pullRequest.ts (1 hunks)
  • app/client/src/git/requests/pullRequest.types.ts (1 hunks)
  • app/client/src/git/requests/toggleAutocommitRequest.ts (1 hunks)
  • app/client/src/git/requests/toggleAutocommitRequest.types.ts (1 hunks)
  • app/client/src/git/requests/triggerAutocommitRequest.ts (1 hunks)
  • app/client/src/git/requests/triggerAutocommitRequest.types.ts (1 hunks)
  • app/client/src/git/requests/updateGlobalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/updateGlobalConfigRequest.types.ts (1 hunks)
  • app/client/src/git/requests/updateLocalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/updateLocalConfigRequest.types.ts (1 hunks)
  • app/client/src/git/requests/updateProtectedBranchesRequest.ts (1 hunks)
  • app/client/src/git/requests/updateProtectedBranchesRequest.types.ts (1 hunks)
  • app/client/src/git/types.ts (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • app/client/src/git/requests/constants.ts
  • app/client/src/git/requests/fetchProtectedBranchesRequest.types.ts
  • app/client/src/git/requests/toggleAutocommitRequest.types.ts
  • app/client/src/git/requests/disconnectRequest.types.ts
  • app/client/src/git/types.ts
🔇 Additional comments (15)
app/client/src/git/requests/updateGlobalConfigRequest.ts (1)

1-7: LGTM: Clean imports and good type usage

The imports are well-organized and types are properly utilized.

app/client/src/git/requests/disconnectRequest.ts (2)

1-4: LGTM! Clean imports with proper type imports

The imports are well-organized and use the 'type' keyword appropriately for TypeScript types.


9-9: Verify API endpoint pattern consistency

Let's verify that this endpoint follows the same pattern as other Git-related endpoints.

✅ Verification successful

API endpoint pattern is consistent

The endpoint /disconnect/app/${baseApplicationId} follows the same pattern as all other Git-related endpoints in the codebase:

  • All endpoints use GIT_BASE_URL as the base
  • All follow the pattern /{action}/app/{applicationId}
  • All use template literals for consistent string interpolation (except deleteBranchRequest.ts which uses string concatenation)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent endpoint patterns in Git-related requests
echo "Checking Git API endpoint patterns..."
rg -g '*.ts' -g '*.js' "GIT_BASE_URL.*app/.*" app/client/src/git/

Length of output: 2634

app/client/src/git/requests/fetchMergeStatusRequest.ts (1)

13-16: Verify the API endpoint structure

Ensure that the API endpoint structure follows RESTful conventions and matches the backend implementation.

✅ Verification successful

Let me gather more information about the API endpoint structure.


Let me search for the base URL constant definition.


API endpoint structure is correctly implemented

The endpoint /v1/git/merge/status/app/{branchedApplicationId} follows RESTful conventions and matches the backend implementation in GitControllerCE.java. The base URL constant is properly defined and the endpoint structure is consistent across client and server.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other API endpoint definitions to verify consistency
rg -g '*.ts' -g '*.js' "GIT_BASE_URL.*merge.*status" --no-filename

Length of output: 133


Script:

#!/bin/bash
# Search for backend route definitions
rg -g '*.ts' -g '*.js' -g '*.java' "/merge/status/app" -A 3 -B 3

# Search for any other merge status related endpoints
rg -g '*.ts' -g '*.js' -g '*.java' "merge.*status" -A 3 -B 3

# Look for the constant definition
rg "GIT_BASE_URL.*=" -g '*.ts' -g '*.js'

Length of output: 71107


Script:

#!/bin/bash
# Search for GIT_BASE_URL constant definition
rg -g '*.ts' -g '*.js' "GIT_BASE_URL\s*=\s*" -A 1

# Search for any other merge status related API endpoints in the backend
rg -g '*.java' "/merge/status" -A 2 -B 2

Length of output: 908

app/client/src/git/requests/updateProtectedBranchesRequest.ts (1)

13-16: Verify error response handling in Api.post

Ensure that the Api.post utility properly handles and transforms API errors.

app/client/src/git/requests/fetchBranchesRequest.ts (1)

1-8: LGTM! Imports are well-organized.

Good use of type imports and clear organization.

app/client/src/git/requests/createBranchRequest.types.ts (1)

1-3: LGTM! Clean and focused request params interface.

The CreateBranchRequestParams interface is well-defined with a single, clear responsibility.

app/client/src/git/requests/createBranchRequest.ts (1)

9-17: Verify error handling strategy.

The implementation looks clean, but we should ensure proper error handling exists in the Api class for failed branch creation scenarios.

✅ Verification successful

Error handling is properly implemented through global interceptors

The implementation is secure with comprehensive error handling through axios interceptors:

  • Global failure interceptor handles multiple error scenarios:
    • HTTP 413 (Payload too large)
    • Network offline errors
    • Request cancellation
    • Action execution errors
    • Timeout errors
    • Server errors (500)
    • Unauthorized (401)
    • Not found (404)
    • Bad requests (400)
  • Success interceptor validates response metadata and handles special cases for action execution
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if Api class implements error handling
ast-grep --pattern 'class Api {
  $$$
  post($_) {
    try {
      $$$
    } catch {
      $$$
    }
  }
  $$$
}'

Length of output: 115


Script:

#!/bin/bash
# Let's try a different approach to find the Api class implementation
rg -l "class Api" --type ts

# Then check for error handling patterns in the Api class
rg "class Api" -A 20 --type ts

# Also search for axios interceptors which are commonly used for global error handling
rg "interceptors" --type ts -A 10

Length of output: 25754


Script:

#!/bin/bash
# Let's check the implementation of the failure interceptor to verify error handling
rg -A 20 "apiFailureResponseInterceptor" --type ts

# Also check the success interceptor implementation
rg -A 20 "apiSuccessResponseInterceptor" --type ts

Length of output: 22968

app/client/src/git/requests/checkoutBranchRequest.ts (1)

13-16: Verify API endpoint structure

Let's ensure the API endpoint follows the REST convention and the base URL is properly configured.

✅ Verification successful

Let me check the Git API endpoint usage patterns more specifically.


API endpoint structure follows consistent pattern

The Git API endpoints follow a consistent RESTful pattern across all Git operations:

  • Base URL is correctly defined as /v1/git
  • Resource paths follow the pattern /{operation}/app/{applicationId}
  • The checkout endpoint /checkout-branch/app/${branchedApplicationId} aligns with this convention
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent API endpoint structure across Git operations

# Search for all Git API endpoint usages
rg -l "${GIT_BASE_URL}" --type ts

# Check for consistent endpoint structure
ast-grep --pattern 'Api.get(`${GIT_BASE_URL}/$$$/app/${$_}`, $_)'

Length of output: 65987


Script:

#!/bin/bash
# Search for Git API endpoint patterns in git-related files
rg -A 2 "GIT_BASE_URL" --type ts app/client/src/git/

# Check for all Git API endpoint usages
rg -A 2 "Api\.get\(`\${GIT_BASE_URL}" --type ts

Length of output: 11797

app/client/src/git/requests/fetchProtectedBranchesRequest.ts (1)

1-10: Verify error handling implementation

Let's ensure consistent error handling for this endpoint across the codebase.

✅ Verification successful

Let me analyze the error handling implementation by checking how the request is used in components and what common error handling patterns exist.


Let me analyze the actual error handling implementation in the Api class and how errors are handled in the consuming code.


Error handling follows standard API patterns

The fetchProtectedBranchesRequest follows the established pattern where:

  • It uses the centralized Api class which handles HTTP requests uniformly
  • Error handling is managed at the application level through axios interceptors
  • Errors are propagated as promises, allowing consumers to handle them appropriately
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of fetchProtectedBranchesRequest to verify error handling
rg -l "fetchProtectedBranchesRequest" | xargs rg -A 10 "fetchProtectedBranchesRequest" 

# Search for similar Git API endpoints to compare error handling patterns
ast-grep --pattern 'Api.get(`${GIT_BASE_URL}$$$`)'

Length of output: 1348


Script:

#!/bin/bash
# Search for error handling patterns in components/pages using this request
rg -A 10 "fetchProtectedBranchesRequest.*then|fetchProtectedBranchesRequest.*catch" 

# Search for error handling in the Api class
rg -A 10 "class Api" 

# Look for common error handling utilities
fd "ApiError|ErrorHandler" --type f

Length of output: 11081


Script:

#!/bin/bash
# Check how errors are handled in the Api class implementation
rg -A 15 "class Api" app/client/src/api/Api.ts

# Look for error handling patterns in sagas or components
rg -A 10 "function\*.*fetchProtectedBranches|function.*fetchProtectedBranches"

# Check the error handler implementation
rg -A 10 "class.*ErrorHandler|function.*ErrorHandler" app/client/src/sagas/EvalErrorHandler.ts

Length of output: 1513

app/client/src/git/requests/mergeRequest.ts (1)

6-11: Implementation looks good, verify error handling

The merge request implementation is clean and well-typed. However, we should verify that the Api class properly handles merge conflicts and error scenarios.

app/client/src/git/requests/fetchGitMetadataRequest.types.ts (2)

1-15: Review required/optional field consistency

There are some inconsistencies in the optional/required fields pattern:

  • browserSupportedUrl is optional but browserSupportedRemoteUrl is required
  • Consider documenting the difference between these URL fields

Let's verify the API response structure:

Also, consider adding JSDoc comments to document the purpose of each field:

 export interface FetchGitMetadataResponse {
+  /** Current branch name */
   branchName: string;
+  /** Default branch name (e.g., main, master) */
   defaultBranchName: string;
+  /** Remote repository URL */
   remoteUrl: string;
   repoName: string;
+  /** Browser-friendly URL for repository access */
   browserSupportedUrl?: string;
   isRepoPrivate?: boolean;
+  /** Browser-friendly remote URL (required for UI operations) */
   browserSupportedRemoteUrl: string;
   defaultApplicationId: string;
   isProtectedBranch: boolean;
+  /** Configuration for automatic commit functionality */
   autoCommitConfig: {
     enabled: boolean;
   };
   isAutoDeploymentEnabled?: boolean;
 }

11-14: Consider expanding autoCommitConfig type

The autoCommitConfig object might need additional properties for configuration flexibility.

Let's check existing usage:

✅ Verification successful

Current autoCommitConfig implementation is sufficient

Based on the codebase analysis, the current autoCommitConfig type with just the enabled property is adequate. The type is consistently used across the codebase (in selectors, sagas, and components) only to check if autocommit is enabled/disabled, with no evidence of additional configuration needs.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for autoCommitConfig usage patterns
ast-grep --pattern 'autoCommitConfig: { $$$' 

Length of output: 46


Script:

#!/bin/bash
# Let's try a more comprehensive search for autoCommitConfig usage
rg -g '*.{ts,tsx,js,jsx}' 'autoCommitConfig' -B 2 -A 2

# Also search for type definitions
ast-grep --pattern 'interface $_  { 
  $$$
  autoCommitConfig
  $$$
}'

# And search for actual object usage
ast-grep --pattern 'autoCommitConfig: {
  enabled: $_
}'

Length of output: 3713

app/client/src/git/requests/commitRequest.ts (1)

13-16: Verify the commit endpoint usage across the application

Let's ensure this endpoint is used consistently across the application.

✅ Verification successful

Let me check the implementation details of these files to ensure consistent usage.


The commit endpoint is used consistently across the application

The endpoint usage is consistent with proper separation of concerns:

  • commitRequest.ts and GitSyncAPI.tsx use the same endpoint pattern for manual commits
  • triggerAutocommitRequest.ts and related code correctly use a separate auto-commit endpoint
  • All implementations use the same API structure and base URL configuration
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for commit endpoint usage patterns
rg -l "commit/app/" --type ts

Length of output: 235


Script:

#!/bin/bash
# Check the implementation details of files using the commit endpoint
rg "commit/app/" -A 5 --type ts

Length of output: 1850

app/client/src/git/requests/fetchStatusRequest.types.ts (1)

1-3: LGTM! Clean and focused interface definition.

app/client/src/git/requests/deleteBranchRequest.ts Outdated Show resolved Hide resolved
app/client/src/git/requests/fetchSSHKeyRequest.ts Outdated Show resolved Hide resolved
app/client/src/git/requests/updateGlobalConfigRequest.ts Outdated Show resolved Hide resolved
app/client/src/git/requests/disconnectRequest.ts Outdated Show resolved Hide resolved
app/client/src/git/requests/commitRequest.ts Outdated Show resolved Hide resolved
app/client/src/git/requests/generateSSHKeyRequest.ts Outdated Show resolved Hide resolved
app/client/src/git/requests/generateSSHKeyRequest.ts Outdated Show resolved Hide resolved
app/client/src/git/requests/fetchStatusRequest.types.ts Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (1)
app/client/src/git/requests/generateSSHKeyRequest.ts (1)

13-15: Consider standardizing the API endpoint structure

The function uses different base URLs (GIT_BASE_URL vs APPLICATION_BASE_URL) for importing vs generating keys. Consider standardizing under a single API namespace for better maintainability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1119f65 and 2900b65.

📒 Files selected for processing (8)
  • app/client/src/git/actions/helpers/singleArtifactInitialState.ts (1 hunks)
  • app/client/src/git/requests/constants.ts (1 hunks)
  • app/client/src/git/requests/deleteBranchRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchLocalConfigRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchLocalConfigRequest.types.ts (1 hunks)
  • app/client/src/git/requests/fetchSSHKeyRequest.ts (1 hunks)
  • app/client/src/git/requests/fetchStatusRequest.types.ts (1 hunks)
  • app/client/src/git/requests/generateSSHKeyRequest.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/git/actions/helpers/singleArtifactInitialState.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • app/client/src/git/requests/fetchLocalConfigRequest.types.ts
  • app/client/src/git/requests/deleteBranchRequest.ts
  • app/client/src/git/requests/fetchLocalConfigRequest.ts
  • app/client/src/git/requests/fetchStatusRequest.types.ts
🧰 Additional context used
📓 Learnings (2)
app/client/src/git/requests/generateSSHKeyRequest.ts (2)
Learnt from: brayn003
PR: appsmithorg/appsmith#37984
File: app/client/src/git/requests/generateSSHKeyRequest.ts:9-18
Timestamp: 2024-12-05T11:06:06.127Z
Learning: In the TypeScript file `app/client/src/git/requests/generateSSHKeyRequest.ts`, the function `generateSSHKeyRequest` does not require error handling and input validation.
Learnt from: brayn003
PR: appsmithorg/appsmith#37984
File: app/client/src/git/requests/fetchSSHKeyRequest.ts:5-9
Timestamp: 2024-12-05T10:56:13.739Z
Learning: In `app/client/src/git/requests/fetchSSHKeyRequest.ts`, the `fetchSSHKeyRequest` function does not require explicit error handling for `baseApplicationId`; the function should throw an error naturally if `baseApplicationId` is missing or invalid.
app/client/src/git/requests/fetchSSHKeyRequest.ts (1)
Learnt from: brayn003
PR: appsmithorg/appsmith#37984
File: app/client/src/git/requests/fetchSSHKeyRequest.ts:5-9
Timestamp: 2024-12-05T10:56:13.739Z
Learning: In `app/client/src/git/requests/fetchSSHKeyRequest.ts`, the `fetchSSHKeyRequest` function does not require explicit error handling for `baseApplicationId`; the function should throw an error naturally if `baseApplicationId` is missing or invalid.
🔇 Additional comments (2)
app/client/src/git/requests/constants.ts (1)

1-2: LGTM! Well-defined API base URLs

The constants are appropriately named and follow REST API versioning conventions.

app/client/src/git/requests/generateSSHKeyRequest.ts (1)

9-18: Verify the dual-purpose endpoint implementation

The implementation looks correct but let's verify both endpoints are properly configured on the backend.

✅ Verification successful

Let me check the implementation details of these endpoints to ensure they handle the key type parameter correctly.


Both endpoints are properly implemented and handle the keyType parameter correctly

The backend implementation confirms:

  • /import/keys GET endpoint in GitControllerCE handles the optional keyType parameter
  • /ssh-keypair/{branchedApplicationId} POST endpoint in ApplicationControllerCE also supports the optional keyType parameter
  • Both endpoints return appropriate response types (GitAuth/GitAuthDTO)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the backend implementations of both endpoints
rg -g '*.{java,kt}' '/import/keys|/ssh-keypair/'

Length of output: 502


Script:

#!/bin/bash
# Check the implementation of both endpoints
ast-grep --pattern 'GetMapping("/import/keys")
  $$$
  $_($$_) {
    $$$
  }' 

ast-grep --pattern 'PostMapping("/ssh-keypair/{branchedApplicationId}")
  $$$
  $_($$_) {
    $$$
  }'

Length of output: 184


Script:

#!/bin/bash
# Let's try with ripgrep to see the implementation details
rg -g '*.{java,kt}' -B 2 -A 10 '/import/keys|/ssh-keypair/'

Length of output: 5367

app/client/src/git/requests/fetchSSHKeyRequest.ts Outdated Show resolved Hide resolved
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2900b65 and 146238c.

📒 Files selected for processing (2)
  • app/client/src/git/components/QuickActions/index.test.tsx (1 hunks)
  • app/client/src/git/components/QuickActions/index.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/git/components/QuickActions/index.tsx
🔇 Additional comments (1)
app/client/src/git/components/QuickActions/index.test.tsx (1)

Line range hint 1-250: LGTM! Test coverage is comprehensive

The test suite thoroughly covers all component behaviors including:

  • Rendering states (connected/disconnected)
  • Button interactions
  • Loading states
  • Count displays
  • Protected mode behavior

@@ -0,0 +1,8 @@
export interface CheckoutBranchRequestParams {
Copy link
Contributor

Choose a reason for hiding this comment

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

We are doing one api per file so why segregate further having types.ts? wouldn't it incur more context switching?

Copy link
Contributor Author

@brayn003 brayn003 Dec 6, 2024

Choose a reason for hiding this comment

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

To avoid circular dependencies.
In case of types in the same file, if I import the response type in say the redux store file. This will happen -
redux store file <- git api file <- request lib file <- redux store file

Copy link
Contributor

Choose a reason for hiding this comment

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

request lib file <- redux store file
Can you give me a reference to this part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image Store is used in request interceptor for determining branch and environment to be included in headers

app/client/src/git/requests/generateSSHKeyRequest.ts Outdated Show resolved Hide resolved
@brayn003 brayn003 merged commit fd9efb8 into release Dec 6, 2024
42 checks passed
@brayn003 brayn003 deleted the chore/git-mod-3 branch December 6, 2024 08:35
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Dec 9, 2024
## Description
- Add application apis for git package

Fixes appsmithorg#37823


## 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/12194637717>
> Commit: e72e02f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12194637717&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Fri, 06 Dec 2024 08:23:16 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 various asynchronous functions for Git operations,
including:
		- `checkoutBranchRequest`
		- `commitRequest`
		- `connectRequest`
		- `createBranchRequest`
		- `deleteBranchRequest`
		- `fetchBranchesRequest`
		- `fetchGitMetadataRequest`
		- `fetchProtectedBranchesRequest`
		- `mergeRequest`
		- `pullRequest`
		- `toggleAutocommitRequest`
		- `triggerAutocommitRequest`
		- `updateGlobalConfigRequest`
		- `updateLocalConfigRequest`
		- `updateProtectedBranchesRequest`
- Added new enumeration `AutocommitStatus` and interfaces to enhance
type safety for Git operations.
- **Bug Fixes**
- Updated import paths for consistency and clarity across multiple
files.
- **Documentation**
- Enhanced type definitions for various request and response structures.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai bot mentioned this pull request Jan 16, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod 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] Git mod - Migrate API request functions
2 participants