diff options
| author | Jason Garber <jason@sixtwothree.org> | 2024-01-31 22:04:50 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-02-16 04:53:14 +0000 |
| commit | 6f224d66a5210b090c095946fd20b9d33868695f (patch) | |
| tree | cf4d0f19af89814e20816e4696e890ec415cd0ba /lib | |
| parent | df8ae9375609a70c1e5517b8d822140b707cfd6a (diff) | |
[rubygems/rubygems] Add `gitlab:` Git source shorthand
This new shorthand, similar to the existing `github:` shorthand, adds
support for Gitlab repositories with a notable difference. Gitlab
projects may be organized into projects and subprojects. An example
Ruby gem exists at:
https://gitlab.com/gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb
With the new shorthand, a user may install this gem from its repository
by adding:
```ruby
gem "gitlab-sdk", gitlab: "gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb"
```
As with the `github:` shorthand, a supplied string with no `/` will be
interpreted as `example/example`.
Also in keeping with the utility of the `github:` shorthand, the new
`gitlab:` shorthand also supports Merge Request URLs.
```ruby
gem "gitlab-sdk", gitlab: "https://gitlab.com/gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb/-/merge_requests/27"
```
The `gitlab:` gem source shortcut is modeled on the existing `github:`
shortcut, so the new specs mimic the existing examples.
https://github.com/rubygems/rubygems/commit/f4399018c0
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bundler/dsl.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 7b342c594a..6af80fb31f 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -19,6 +19,7 @@ module Bundler platform platforms type source install_if gemfile force_ruby_platform].freeze GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z} + GITLAB_MERGE_REQUEST_URL = %r{\Ahttps://gitlab\.com/([A-Za-z0-9_\-\./]+)/-/merge_requests/(\d+)\z} attr_reader :gemspecs, :gemfile attr_accessor :dependencies @@ -308,6 +309,20 @@ module Bundler repo_name ||= user_name "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git" end + + git_source(:gitlab) do |repo_name| + if repo_name =~ GITLAB_MERGE_REQUEST_URL + { + "git" => "https://gitlab.com/#{$1}.git", + "branch" => nil, + "ref" => "refs/merge-requests/#{$2}/head", + "tag" => nil, + } + else + repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") + "https://gitlab.com/#{repo_name}.git" + end + end end def with_source(source) |
