diff options
-rw-r--r-- | lib/bundler/cli/plugin.rb | 10 | ||||
-rw-r--r-- | lib/bundler/plugin/installer.rb | 6 | ||||
-rw-r--r-- | spec/plugins/install_spec.rb | 11 |
3 files changed, 26 insertions, 1 deletions
diff --git a/lib/bundler/cli/plugin.rb b/lib/bundler/cli/plugin.rb index 92d4653bda..ea50199843 100644 --- a/lib/bundler/cli/plugin.rb +++ b/lib/bundler/cli/plugin.rb @@ -5,7 +5,13 @@ module Bundler class CLI::Plugin < Thor desc "install PLUGINS", "Install the plugin from the source" long_desc <<-D - Install plugins either from the rubygems source provided (with --source option) or from a git source provided with (--git option). If no sources are provided, it uses Gem.sources + Install plugins from any of the sources provided: + + - from rubygems (`--source` option) + - from a remote git source (`--git` option) + - from a local git repo (`--file /path/to/repo` option) + + If no sources are provided, it uses Gem.sources. D method_option "source", :type => :string, :default => nil, :banner => "URL of the RubyGems source to fetch the plugin from" @@ -13,6 +19,8 @@ module Bundler "The version of the plugin to fetch" method_option "git", :type => :string, :default => nil, :banner => "URL of the git repo to fetch from" + method_option "file", :type => :string, :default => nil, :banner => + "Path of the local git repo to fetch from" method_option "branch", :type => :string, :default => nil, :banner => "The git branch to checkout" method_option "ref", :type => :string, :default => nil, :banner => diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb index 6c8744c2f4..9536ca3f1d 100644 --- a/lib/bundler/plugin/installer.rb +++ b/lib/bundler/plugin/installer.rb @@ -40,6 +40,7 @@ module Bundler sources = {} sources[:git] = options.delete(:git) if options[:git] + sources[:file] = options.delete(:file) if options[:file] sources[:source] = options.delete(:source) if options[:source] sources @@ -52,6 +53,11 @@ module Bundler source_list.add_git_source(options.merge("uri" => sources[:git])) end + if sources[:file] + file_uri = "file://#{URI.escape(sources[:file])}" + source_list.add_git_source(options.merge("uri" => file_uri)) + end + if sources[:source] source_list.add_rubygems_source("remotes" => sources[:source]) end diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb index 9304d78062..7c0212ed76 100644 --- a/spec/plugins/install_spec.rb +++ b/spec/plugins/install_spec.rb @@ -122,6 +122,17 @@ RSpec.describe "bundler plugin install" do expect(out).to include("Installed plugin foo") plugin_should_be_installed("foo") end + + it "installs form a local git source" do + build_git "foo" do |s| + s.write "plugins.rb" + end + + bundle "plugin install foo --file #{lib_path("foo-1.0")}" + + expect(out).to include("Installed plugin foo") + plugin_should_be_installed("foo") + end end context "Gemfile eval" do |