diff options
author | David Marshall <depmarshall@gmail.com> | 2024-04-04 12:33:03 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-04-12 13:31:43 +0000 |
commit | c4b5f3f1422b1c83bc4c7e03d32218881c0b6945 (patch) | |
tree | bc3e338e5d93fb5e1176710da2896bd4e66524e6 /lib | |
parent | f1d9e895b92953add4b12f477c27852cc3d0955b (diff) |
[rubygems/rubygems] bundler CLI option for add gem --glob=
Bundler online documentation says that if the gem is located within a subdirectory of a git repository,
you can use the `:glob` option to specify the location of its .gemspec
`gem 'cf-copilot', git: 'https://github.com/cloudfoundry/copilot', glob: 'sdk/ruby/*.gemspec'`
This change allows for equivalent functionality from the bundler CLI
`bundle add cf-copilot --git=https://github.com/cloudfoundry/copilot --glob=sdk/ruby/*.gemspec`
https://github.com/rubygems/rubygems/commit/91052e5868
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/cli.rb | 1 | ||||
-rw-r--r-- | lib/bundler/dependency.rb | 3 | ||||
-rw-r--r-- | lib/bundler/injector.rb | 3 |
3 files changed, 5 insertions, 2 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 3640536762..6ee86b182f 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -347,6 +347,7 @@ module Bundler method_option "github", type: :string method_option "branch", type: :string method_option "ref", type: :string + method_option "glob", type: :string method_option "skip-install", type: :boolean, banner: "Adds gem to the Gemfile but does not install it" method_option "optimistic", type: :boolean, banner: "Adds optimistic declaration of version to gem" method_option "strict", type: :boolean, banner: "Adds strict declaration of version to gem" diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index 77d7a00362..2a4f72fe55 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -7,7 +7,7 @@ require_relative "rubygems_ext" module Bundler class Dependency < Gem::Dependency attr_reader :autorequire - attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref + attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :glob ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..34).to_a).freeze PLATFORM_MAP = { @@ -39,6 +39,7 @@ module Bundler @github = options["github"] @branch = options["branch"] @ref = options["ref"] + @glob = options["glob"] @platforms = Array(options["platforms"]) @env = options["env"] @should_include = options.fetch("should_include", true) diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb index cf561c2ee4..879b481339 100644 --- a/lib/bundler/injector.rb +++ b/lib/bundler/injector.rb @@ -120,9 +120,10 @@ module Bundler github = ", :github => \"#{d.github}\"" unless d.github.nil? branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil? ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil? + glob = ", :glob => \"#{d.glob}\"" unless d.glob.nil? require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil? - %(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{require_path}) + %(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{glob}#{require_path}) end.join("\n") end |