summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColby Swandale <colby@taplaboratories.com>2017-04-08 12:44:28 +1000
committerColby Swandale <colby@taplaboratories.com>2017-04-08 13:02:34 +1000
commit261afb919826d14b2c2b72c290635b11f3e1de7b (patch)
tree4aba7555fc6fbf6cebb56b06b18124e1872eb172
parent344f487a4ca2ad6d41c22291a04c46dd7006bac0 (diff)
downloadbundler-261afb919826d14b2c2b72c290635b11f3e1de7b.tar.gz
fix using branch with git_source with spec
-rw-r--r--lib/bundler/dsl.rb3
-rw-r--r--spec/bundler/dsl_spec.rb7
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index b1f2dec39e..9bbabfee19 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -385,7 +385,8 @@ module Bundler
def validate_keys(command, opts, valid_keys)
invalid_keys = opts.keys - valid_keys
- if opts["branch"] && !(opts["git"] || opts["github"])
+ git_source = opts.keys & @git_sources.keys.map(&:to_s)
+ if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?)
raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch)
end
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index 5537dd7a48..4f5eb6dc92 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -155,6 +155,13 @@ RSpec.describe Bundler::Dsl do
dep = subject.dependencies.last
expect(dep.name).to eq "foo"
end
+
+ it "allows specifiying a branch on git gems with a git_source" do
+ subject.git_source(:test_source) {|n| "https://github.com/#{n}" }
+ subject.gem("foo", :branch => "test", :test_source => "bundler/bundler")
+ dep = subject.dependencies.last
+ expect(dep.name).to eq "foo"
+ end
end
describe "#gemspec" do