Conversation
# Conflicts: # src/otomi-stack.test.ts
There was a problem hiding this comment.
Pull request overview
This PR refactors Git repository connectivity/branch retrieval by centralizing authentication and Git client creation (including support for token-only HTTPS auth), and improves connectivity-test error reporting back to API clients.
Changes:
- Introduces
getAuthenticatedGitClient()to normalize repo URLs and apply SSH/HTTPS auth based on team secrets or internal Gitea credentials. - Refactors branch listing and connectivity testing to use the shared auth/client logic and to propagate/return errors more consistently.
- Updates tests and OpenAPI schema to include an optional
messageinTestRepoConnectresponses.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/codeRepoUtils.ts | Adds unified authenticated Git client creation and refactors ref extraction. |
| src/utils/codeRepoUtils.test.ts | Updates unit tests to cover the new auth/client behavior and new error propagation. |
| src/otomi-stack.ts | Switches branch retrieval and connectivity tests to the new shared Git client/auth flow and returns failure messages. |
| src/otomi-stack.test.ts | Adds tests for getRepoBranches() and getTestRepoConnect() using the new helpers and cleanup behavior. |
| src/openapi/testrepoconnect.yaml | Extends response schema with a message field for failure details. |
| src/git/connect.ts | Updates getAuthenticatedUrl() typing and supports token-only auth (no username) by embedding token as the URL “username”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| expect(result).toEqual([]) | ||
| }) | ||
|
|
||
| it('should clean up the SSH key file after fetching branches', async () => { |
There was a problem hiding this comment.
shouldn't the keypath also be cleaned up in case an error is thrown?
| if (!username || !accessToken) throw new Error('Username and access token are required for HTTPS authentication') | ||
| url = repoUrl.replace('https://', `https://${encodeURIComponent(username)}:${encodeURIComponent(accessToken)}@`) | ||
| } else throw new Error('Invalid repository URL format. Must be SSH or HTTPS.') | ||
| export function isInteralGiteaURL(repositoryUrl: string, clusterDomainSuffix?: string) { |
There was a problem hiding this comment.
not a blocker but this should be isInternalGiteaURL not Iteral. Would recommend to fix if it's not too complex
dennisvankekem
left a comment
There was a problem hiding this comment.
Left some minor comments but the rest looks good
This PR includes the following fixes and improvements:
The refactored code merges the logic of creating a Git client, making it easier in the future to attach and maintain functionality. The chart retrieval could still use refactoring to support SSH in the future.
Note that SSH code repositories are currently not supported, as the OpenAPI validation rejects them.