mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Add github
and ref
options to bundle add
c3e54acab0
This commit is contained in:
parent
5f1975a454
commit
1a62a50c4f
6 changed files with 59 additions and 6 deletions
|
@ -369,7 +369,9 @@ module Bundler
|
|||
method_option "source", :aliases => "-s", :type => :string
|
||||
method_option "require", :aliases => "-r", :type => :string, :banner => "Adds require path to gem. Provide false, or a path as a string."
|
||||
method_option "git", :type => :string
|
||||
method_option "github", :type => :string
|
||||
method_option "branch", :type => :string
|
||||
method_option "ref", :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"
|
||||
|
|
|
@ -7,7 +7,7 @@ require_relative "rubygems_ext"
|
|||
module Bundler
|
||||
class Dependency < Gem::Dependency
|
||||
attr_reader :autorequire
|
||||
attr_reader :groups, :platforms, :gemfile, :git, :branch
|
||||
attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref
|
||||
|
||||
PLATFORM_MAP = {
|
||||
:ruby => Gem::Platform::RUBY,
|
||||
|
@ -82,7 +82,9 @@ module Bundler
|
|||
@groups = Array(options["group"] || :default).map(&:to_sym)
|
||||
@source = options["source"]
|
||||
@git = options["git"]
|
||||
@github = options["github"]
|
||||
@branch = options["branch"]
|
||||
@ref = options["ref"]
|
||||
@platforms = Array(options["platforms"])
|
||||
@env = options["env"]
|
||||
@should_include = options.fetch("should_include", true)
|
||||
|
|
|
@ -112,10 +112,12 @@ module Bundler
|
|||
|
||||
source = ", :source => \"#{d.source}\"" unless d.source.nil?
|
||||
git = ", :git => \"#{d.git}\"" unless d.git.nil?
|
||||
github = ", :github => \"#{d.github}\"" unless d.github.nil?
|
||||
branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
|
||||
ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil?
|
||||
require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
|
||||
|
||||
%(gem #{name}#{requirement}#{group}#{source}#{git}#{branch}#{require_path})
|
||||
%(gem #{name}#{requirement}#{group}#{source}#{git}#{github}#{branch}#{ref}#{require_path})
|
||||
end.join("\n")
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-git=GIT] [\-\-branch=BRANCH] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
|
||||
\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-git=GIT] [\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
|
||||
|
@ -49,10 +49,18 @@ Specify the source for the added gem\.
|
|||
Specify the git source for the added gem\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-github\fR
|
||||
Specify the github source for the added gem\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-branch\fR
|
||||
Specify the git branch for the added gem\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-ref\fR
|
||||
Specify the git ref for the added gem\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-skip\-install\fR
|
||||
Adds the gem to the Gemfile but does not install it\.
|
||||
.
|
||||
|
|
|
@ -3,7 +3,7 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--git=GIT] [--branch=BRANCH] [--skip-install] [--strict] [--optimistic]
|
||||
`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--git=GIT] [--github=GITHUB] [--branch=BRANCH] [--ref=REF] [--skip-install] [--strict] [--optimistic]
|
||||
|
||||
## DESCRIPTION
|
||||
Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`.
|
||||
|
@ -33,9 +33,15 @@ bundle add rails --group "development, test"
|
|||
* `--git`:
|
||||
Specify the git source for the added gem.
|
||||
|
||||
* `--github`:
|
||||
Specify the github source for the added gem.
|
||||
|
||||
* `--branch`:
|
||||
Specify the git branch for the added gem.
|
||||
|
||||
* `--ref`:
|
||||
Specify the git ref for the added gem.
|
||||
|
||||
* `--skip-install`:
|
||||
Adds the gem to the Gemfile but does not install it.
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ RSpec.describe "bundle add" do
|
|||
end
|
||||
|
||||
describe "with --git" do
|
||||
it "adds dependency with specified github source" do
|
||||
it "adds dependency with specified git source" do
|
||||
bundle "add foo --git=#{lib_path("foo-2.0")}"
|
||||
|
||||
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/)
|
||||
|
@ -117,7 +117,7 @@ RSpec.describe "bundle add" do
|
|||
update_git "foo", "2.0", :branch => "test"
|
||||
end
|
||||
|
||||
it "adds dependency with specified github source and branch" do
|
||||
it "adds dependency with specified git source and branch" do
|
||||
bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test"
|
||||
|
||||
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/)
|
||||
|
@ -125,6 +125,39 @@ RSpec.describe "bundle add" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "with --git and --ref" do
|
||||
it "adds dependency with specified git source and branch" do
|
||||
bundle "add foo --git=#{lib_path("foo-2.0")} --ref=#{revision_for(lib_path("foo-2.0"))}"
|
||||
|
||||
expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2\.0", :git => "#{lib_path("foo-2.0")}", :ref => "#{revision_for(lib_path("foo-2.0"))}"/)
|
||||
expect(the_bundle).to include_gems "foo 2.0"
|
||||
end
|
||||
end
|
||||
|
||||
describe "with --github" do
|
||||
it "adds dependency with specified github source" do
|
||||
bundle "add rake --github=ruby/rake"
|
||||
|
||||
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake"})
|
||||
end
|
||||
end
|
||||
|
||||
describe "with --github and --branch" do
|
||||
it "adds dependency with specified github source and branch" do
|
||||
bundle "add rake --github=ruby/rake --branch=master"
|
||||
|
||||
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake", :branch => "master"})
|
||||
end
|
||||
end
|
||||
|
||||
describe "with --github and --ref" do
|
||||
it "adds dependency with specified github source and ref" do
|
||||
bundle "add rake --github=ruby/rake --ref=5c60da8"
|
||||
|
||||
expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.0", :github => "ruby\/rake", :ref => "5c60da8"})
|
||||
end
|
||||
end
|
||||
|
||||
describe "with --skip-install" do
|
||||
it "adds gem to Gemfile but is not installed" do
|
||||
bundle "add foo --skip-install --version=2.0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue