-
-
Notifications
You must be signed in to change notification settings - Fork 2k
bundle inject
with source and group options
#5456
bundle inject
with source and group options
#5456
Conversation
f58089b
to
b7689f4
Compare
b7689f4
to
67ee37f
Compare
lib/bundler/cli/inject.rb
Outdated
@@ -31,7 +31,7 @@ def run | |||
|
|||
if added.any? | |||
Bundler.ui.confirm "Added to Gemfile:" | |||
Bundler.ui.confirm added.map {|g| " #{g}" }.join("\n") | |||
Bundler.ui.confirm added.map {|g| " #{g}, group => #{g.groups.inspect}, :source => '#{g.source}'" }.join("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably use source.dump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't understand what this means ? @segiddins, Can you tell me what should be replaced.
Edit : I have edited the line :source => '#{g.source.dump}'"
. Thanks for review.
spec/commands/inject_spec.rb
Outdated
@@ -52,6 +52,29 @@ | |||
end | |||
end | |||
|
|||
context "use source and group options" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please separate the source
and group
options into separate contexts
spec/commands/inject_spec.rb
Outdated
gemfile = bundled_app("Gemfile").read | ||
str = "gem 'bootstrap', '> 0', :source => 'https://rubygems.org'" | ||
expect(gemfile).to match(/str/) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to use include
instead if we're not using a regex with match
. Example:
expect(gemfile).to include "gem 'bootstrap', '> 0', :source => 'https://rubygems.org'"
Same with the other expectations below as well.
@@ -465,10 +465,14 @@ def platform | |||
end | |||
|
|||
desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile" | |||
method_option "source", :type => :string, :banner => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "install gem from the given source"
and "Install gem into a bundler group"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review @colby-swandale . I have edited the PR according to to your comments.
45345b0
to
15a0208
Compare
I didn't get why I am getting https://travis-ci.org/bundler/bundler/jobs/203772974#L425 error in test, while it is working fine when we run this I think this is the main error Edit : This issue is fixed (Now I am using repo source file for the testcase). |
7e2aae7
to
dd31394
Compare
dd31394
to
b78a3f0
Compare
I have done the required changes and travis build passed as well. Please review it now. |
Ping @colby-swandale @segiddins @indirect , please review. |
Please be patient, we will get around to reviewing the PR when we can. |
lib/bundler/cli/inject.rb
Outdated
@@ -31,7 +31,7 @@ def run | |||
|
|||
if added.any? | |||
Bundler.ui.confirm "Added to Gemfile:" | |||
Bundler.ui.confirm added.map {|g| " #{g}" }.join("\n") | |||
Bundler.ui.confirm added.map {|g| " #{g}, group => #{g.groups.inspect}, :source => '#{g.source.dump}'" }.join("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should only include the groups and the source if they're passed in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review. I have added new msg in this commit
end | ||
|
||
context "with group option" do | ||
it "add gem with group option in gemfile" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also add a test for including multiple groups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review I have added the testcase for multiple groups in this commit
ping @Shekharrajak |
Sorry I completely missed the notification. I will edit the PR accordingly soon. |
@colby-swandale , @segiddins Please review once when you get time . Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 other than the one question
spec/commands/inject_spec.rb
Outdated
it "add gem with multiple group in gemfile" do | ||
bundle "inject 'rack-obama' '>0' --group=development,test" | ||
gemfile = bundled_app("Gemfile").read | ||
str = "gem 'rack-obama', '> 0', :group => [:development, :test]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be groups
instead of group
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @segiddins for review. I have edited the line in this commit 1f466c0
Sorry for the silly mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I edited this line : "add gem with multiple group in gemfile" to "add gem with multiple groups in gemfile"
and I think this line : gem 'rack-obama', '> 0', :group => [:development, :test]
is correct. I followed this link : http://bundler.io/v1.3/groups.html examples .
spec/commands/inject_spec.rb
Outdated
it "add gem with multiple groups in gemfile" do | ||
bundle "inject 'rack-obama' '>0' --group=development,test" | ||
gemfile = bundled_app("Gemfile").read | ||
str = "gem 'rack-obama', '> 0', :group => [:development, :test]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still reads group
, and given it's the key for an array it should be groups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@segiddins , I saw example here : http://bundler.io/v1.3/groups.html . In gemfile it must be :group => [:development, :test]
right ? I haven't see groups
in gemfile.
To install all dependencies, except those in specified groups
we do something :
$ bundle install --without test development
will it work when we write groups
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be groups
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @segiddins , I have changed it in this commit 1754e50
a4554f1
to
1754e50
Compare
if d.groups != Array(:default) | ||
group = | ||
if d.groups.size == 1 | ||
", :group => #{d.groups.inspect}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's just one group, we shouldn't need to put it in an array
@bundlerbot r+ |
📌 Commit 1754e50 has been approved by |
…y-swandale `bundle inject` with source and group options Fixes #5452 Eg ``` $ bundle inject "bootstrap" ">0" --source=https://rubygems.org --group=development Fetching gem metadata from https://rubygems.org/............ Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Fetching gem metadata from https://rubygems.org/............. Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Added to Gemfile: bootstrap (> 0), group => [:development], :source => 'https://rubygems.org' ``` In GemFile ``` gem 'bootstrap', '> 0', :group => [:development], :source => 'https://rubygems.org' ``` ### Multiple group : ``` $ dbundle inject "bootstrap" ">0" --source=https://rubygems.org --group=development,production Fetching gem metadata from https://rubygems.org/............ Added to Gemfile: gem 'bootstrap', '> 0', :group => [:development, :production], :source => 'https://rubygems.org' ``` In gemfile ``` # Added at 2017-03-24 11:40:51 +0530 by shekharrajak: gem 'bootstrap', '> 0', :group => [:development, :production], :source => 'https://rubygems.org' ```
☀️ Test successful - status-travis |
Fixes #5452
Eg
In GemFile
Multiple group :
In gemfile