summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaverio Miroddi <saverio.pub2@gmail.com>2018-03-19 12:37:00 +0100
committerSaverio Miroddi <saverio.pub2@gmail.com>2018-03-19 12:39:54 +0100
commit39258c0453c7cff7c504158dad20e679ad37c5e5 (patch)
tree341d531d1d4ac59b21e118715ff43de3e11071fe
parent354ee6291593a8838c9424ae8fdab21d3a1d8c87 (diff)
downloadbundler-39258c0453c7cff7c504158dad20e679ad37c5e5.tar.gz
Plugin installer: make remote and local git source options mutually exclusive
-rw-r--r--lib/bundler/plugin/installer.rb18
-rw-r--r--spec/plugins/install_spec.rb7
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index c80f9b1b10..a22402f7a5 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -12,10 +12,15 @@ module Bundler
autoload :Git, "bundler/plugin/installer/git"
def install(names, options)
+ check_sources_consistency!(options)
+
version = options[:version] || [">= 0"]
+
Bundler.settings.temporary(:lockfile_uses_separate_rubygems_sources => false, :disable_multisource => false) do
if options[:git]
install_git(names, version, options)
+ elsif options[:file]
+ install_local_git(names, version, options)
else
sources = options[:source] || Bundler.rubygems.sources
install_rubygems(names, version, sources)
@@ -38,6 +43,12 @@ module Bundler
private
+ def check_sources_consistency!(options)
+ if options[:git] && options[:file]
+ raise InvalidOption, "Remote and local plugin git sources can't be both specified"
+ end
+ end
+
def install_git(names, version, options)
uri = options.delete(:git)
options["uri"] = uri
@@ -45,6 +56,13 @@ module Bundler
install_all_sources(names, version, options, options[:source])
end
+ def install_local_git(names, version, options)
+ uri = options.delete(:file)
+ options["uri"] = uri
+
+ install_all_sources(names, version, options, options[:source])
+ end
+
# Installs the plugin from rubygems source and returns the path where the
# plugin was installed
#
diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb
index 7c0212ed76..50d380ea8c 100644
--- a/spec/plugins/install_spec.rb
+++ b/spec/plugins/install_spec.rb
@@ -133,6 +133,13 @@ RSpec.describe "bundler plugin install" do
expect(out).to include("Installed plugin foo")
plugin_should_be_installed("foo")
end
+
+ it "raises an error when both git and local git sources are specified" do
+ bundle "plugin install foo --file /phony/path/project --git git@gitphony.com:/repo/project"
+
+ expect(exitstatus).not_to eq(0) if exitstatus
+ expect(out).to eq("Remote and local plugin git sources can't be both specified")
+ end
end
context "Gemfile eval" do