feat(spm): add support for self-hosted and GitLab repositories#6358
feat(spm): add support for self-hosted and GitLab repositories#6358
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for GitLab and self-hosted repositories to the SPM (Swift Package Manager) backend. It introduces a provider-based approach similar to other backends in the codebase, allowing users to specify GitLab or self-hosted Git repositories as sources for SPM packages.
Key changes:
- Added
GitProviderstruct andGitProviderKindenum to handle multiple Git providers (GitHub, GitLab) - Modified repository URL parsing to support GitLab and self-hosted instances
- Updated the release fetching logic to use provider-specific APIs
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/backend/spm.rs | Added GitProvider infrastructure, updated SwiftPackageRepo to handle multiple providers, and modified release fetching logic |
| docs/dev-tools/backends/spm.md | Updated documentation to reflect GitLab support and added tool options section |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
bugbot run |
1dcf63b to
1d8111a
Compare
1d8111a to
ec4ce03
Compare
|
bugbot run |
| }; | ||
| let url_str = format!("https://{}/{}.git", host, name); | ||
| let url = Url::parse(&url_str)?; | ||
| (name, url) |
There was a problem hiding this comment.
Bug: SPM Incorrectly Constructs URLs for Custom Git Providers
Shorthand SPM package notation with self-hosted Git providers constructs incorrect clone URLs. The SwiftPackageRepo hardcodes github.com or gitlab.com as the host instead of extracting it from the GitProvider's api_url, which prevents cloning from custom instances.
There was a problem hiding this comment.
I did not account for supporting shorthand notation for self-hosted repositories. Not sure we can reliably derive the repository URL from the API URL, so i rather only have support for self-hosted via https:// notation. This should probably be stated in the docs though.
As requested in #6299, this adds support for the SPM backed for GitLab and self-hosted repositories. It uses the same ToolOptions patterns (
provider,api_url) as used in Ubi, GitHub/GitLab backends.