EPILIBS-192 Wrap API Endpoints: Git#159
Conversation
Summary of ChangesHello, 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 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| export interface GitIntegrationUpdateInView { | ||
| privateKey?: string | null; | ||
| privateKeySpec: unknown; | ||
| publicKey?: string | null; | ||
| uri?: string | null; | ||
| publicKeySpec: unknown; | ||
| algorithm: unknown; | ||
| } |
There was a problem hiding this comment.
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.
| 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; | |
| } |
| export interface GitIntegrationCreateInView { | ||
| privateKey: string; | ||
| privateKeySpec: unknown; | ||
| publicKey: string; | ||
| uri: string; | ||
| publicKeySpec: unknown; | ||
| algorithm: unknown; | ||
| } |
There was a problem hiding this comment.
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.
| 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; | |
| } |
| 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(); | ||
| }); |
There was a problem hiding this comment.
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.
EPILIBS-192
Adds
gitAdapterto wrap git endpointA few design notes:
{ branch }in optionals rather than a positional param — avoids the awkwardreset(undefined, options)call patternconfirmoption maps to theX-Forio-Confirmationheader, following the same pattern asrunAdapterforce on both push and pull goes in the query string via
.withSearchParams()