Skip to content

EPILIBS-192 Wrap API Endpoints: Git#159

Open
zephyr-c wants to merge 1 commit into
masterfrom
EPILIBS-192
Open

EPILIBS-192 Wrap API Endpoints: Git#159
zephyr-c wants to merge 1 commit into
masterfrom
EPILIBS-192

Conversation

@zephyr-c

@zephyr-c zephyr-c commented Mar 23, 2026

Copy link
Copy Markdown

EPILIBS-192

Adds gitAdapter to wrap git endpoint

A few design notes:

  • reset takes an optional { branch } in optionals rather than a positional param — avoids the awkward reset(undefined, options) call pattern
  • pull's confirm option maps to the X-Forio-Confirmation header, following the same pattern as runAdapter
    force on both push and pull goes in the query string via .withSearchParams()

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the API client's capabilities by integrating a comprehensive Git adapter. This new adapter provides a structured and convenient way to interact with Git-related functionalities, such as managing repository integrations, checking status, and performing common Git actions like checking out branches, resetting, pushing, and pulling. The implementation focuses on developer experience by handling optional parameters and specific header requirements for certain operations.

Highlights

  • New Git Adapter: Introduced a new gitAdapter to wrap various Git API endpoints, providing functions for managing Git integrations, status, and operations like checkout, reset, push, and pull.
  • Flexible Reset Method: The reset method was designed to accept an optional branch parameter within its options object, avoiding awkward positional undefined arguments.
  • Confirmation Header for Pull: The pull method now correctly maps its confirm option to the X-Forio-Confirmation header, aligning with existing patterns for confirmation.
  • Query String for Force Operations: The force option for both push and pull operations is now passed via the URL's query string using .withSearchParams().

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new gitAdapter to wrap the Git API endpoints. The implementation is well-structured and includes a comprehensive test suite. My review focuses on improving the type definitions for better developer experience and type safety, and suggesting an enhancement to the test coverage for a specific edge case in header handling. Overall, the changes are good and the adapter will be a valuable addition.

Comment thread src/adapters/git.ts
Comment on lines +30 to +37
export interface GitIntegrationUpdateInView {
privateKey?: string | null;
privateKeySpec: unknown;
publicKey?: string | null;
uri?: string | null;
publicKeySpec: unknown;
algorithm: unknown;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In GitIntegrationUpdateInView, some properties (privateKeySpec, publicKeySpec, algorithm) are marked as required, while others are optional. For an update/PATCH operation, it's typical for all fields to be optional, allowing clients to update only the fields they need to change. The JSDoc @param integration Fields to update on the git integration also suggests this. Consider making all properties in this interface optional.

Additionally, these properties are typed as unknown. As with GitIntegrationCreateInView, they should likely be string for better type safety.

Suggested change
export interface GitIntegrationUpdateInView {
privateKey?: string | null;
privateKeySpec: unknown;
publicKey?: string | null;
uri?: string | null;
publicKeySpec: unknown;
algorithm: unknown;
}
export interface GitIntegrationUpdateInView {
privateKey?: string | null;
privateKeySpec?: string;
publicKey?: string | null;
uri?: string | null;
publicKeySpec?: string;
algorithm?: string;
}

Comment thread src/adapters/git.ts
Comment on lines +21 to +28
export interface GitIntegrationCreateInView {
privateKey: string;
privateKeySpec: unknown;
publicKey: string;
uri: string;
publicKeySpec: unknown;
algorithm: unknown;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The properties privateKeySpec, publicKeySpec, and algorithm are typed as unknown. Based on the example usage in the createIntegration function's JSDoc, these appear to be strings. Using string instead of unknown would improve type safety and developer experience for users of this adapter, as it would remove the need for type assertions.

Suggested change
export interface GitIntegrationCreateInView {
privateKey: string;
privateKeySpec: unknown;
publicKey: string;
uri: string;
publicKeySpec: unknown;
algorithm: unknown;
}
export interface GitIntegrationCreateInView {
privateKey: string;
privateKeySpec: string;
publicKey: string;
uri: string;
publicKeySpec: string;
algorithm: string;
}

Comment thread tests/git.spec.js
Comment on lines +371 to +381
it('Should set X-Forio-Confirmation header when confirm is true', async () => {
await gitAdapter.pull({ confirm: true });
const req = capturedRequests[capturedRequests.length - 1];
expect(getPermitHeader(req.requestHeaders)).toBeTruthy();
});

it('Should not set X-Forio-Confirmation header when confirm is falsy', async () => {
await gitAdapter.pull();
const req = capturedRequests[capturedRequests.length - 1];
expect(getPermitHeader(req.requestHeaders)).toBeFalsy();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The tests for gitAdapter.pull cover the basic cases for the confirm option, but they don't test the interaction with optionals.headers (headersOverride). The implementation logic for merging headers could be complex, so it would be beneficial to add tests for cases where headers are passed in optionals, both with and without the X-Forio-Confirmation header, to ensure the merging logic is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant