Skip to content

Commit

Permalink
Deprecate bundle plugin install --local-git=
Browse files Browse the repository at this point in the history
It's the exact same implementation as --git
  • Loading branch information
ccutrer authored and deivid-rodriguez committed Mar 13, 2024
1 parent 7316186 commit 149b929
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 22 deletions.
4 changes: 2 additions & 2 deletions bundler/lib/bundler/cli/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ 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 (for remote repos) or --local_git (for local repos). If no sources are provided, it uses Gem.sources
Install plugins either from the rubygems source provided (with --source option) or from a git source provided with --git. 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"
method_option "version", type: :string, default: nil, banner: "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 "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from"
method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from (deprecated)"
method_option "branch", type: :string, default: nil, banner: "The git branch to checkout"
method_option "ref", type: :string, default: nil, banner: "The git revision to check out"
def install(*plugins)
Expand Down
6 changes: 3 additions & 3 deletions bundler/lib/bundler/man/bundle-plugin.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.SH "NAME"
\fBbundle\-plugin\fR \- Manage Bundler plugins
.SH "SYNOPSIS"
\fBbundle plugin\fR install PLUGINS [\-\-source=\fISOURCE\fR] [\-\-version=\fIversion\fR] [\-\-git|\-\-local_git=\fIgit\-url\fR] [\-\-branch=\fIbranch\fR|\-\-ref=\fIrev\fR]
\fBbundle plugin\fR install PLUGINS [\-\-source=\fISOURCE\fR] [\-\-version=\fIversion\fR] [\-\-git=\fIgit\-url\fR] [\-\-branch=\fIbranch\fR|\-\-ref=\fIrev\fR]
.br
\fBbundle plugin\fR uninstall PLUGINS
.br
Expand All @@ -27,7 +27,7 @@ Install bundler\-graph gem from example\.com\. The global source, specified in s
You can specify the version of the gem via \fB\-\-version\fR\.
.TP
\fBbundle plugin install bundler\-graph \-\-git https://github\.com/rubygems/bundler\-graph\fR
Install bundler\-graph gem from Git repository\. \fB\-\-git\fR can be replaced with \fB\-\-local\-git\fR\. You cannot use both \fB\-\-git\fR and \fB\-\-local\-git\fR\. You can use standard Git URLs like:
Install bundler\-graph gem from Git repository\. You can use standard Git URLs like:
.IP
\fBssh://[user@]host\.xz[:port]/path/to/repo\.git\fR
.br
Expand All @@ -37,7 +37,7 @@ Install bundler\-graph gem from Git repository\. \fB\-\-git\fR can be replaced w
.br
\fBfile:///path/to/repo\fR
.IP
When you specify \fB\-\-git\fR/\fB\-\-local\-git\fR, you can use \fB\-\-branch\fR or \fB\-\-ref\fR to specify any branch, tag, or commit hash (revision) to use\. When you specify both, only the latter is used\.
When you specify \fB\-\-git\fR, you can use \fB\-\-branch\fR or \fB\-\-ref\fR to specify any branch, tag, or commit hash (revision) to use\. When you specify both, only the latter is used\.
.SS "uninstall"
Uninstall the plugin(s) specified in PLUGINS\.
.SS "list"
Expand Down
6 changes: 3 additions & 3 deletions bundler/lib/bundler/man/bundle-plugin.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bundle-plugin(1) -- Manage Bundler plugins
## SYNOPSIS

`bundle plugin` install PLUGINS [--source=<SOURCE>] [--version=<version>]
[--git|--local_git=<git-url>] [--branch=<branch>|--ref=<rev>]<br>
[--git=<git-url>] [--branch=<branch>|--ref=<rev>]<br>
`bundle plugin` uninstall PLUGINS<br>
`bundle plugin` list<br>
`bundle plugin` help [COMMAND]
Expand All @@ -29,14 +29,14 @@ Install the given plugin(s).
You can specify the version of the gem via `--version`.

* `bundle plugin install bundler-graph --git https://github.com/rubygems/bundler-graph`:
Install bundler-graph gem from Git repository. `--git` can be replaced with `--local-git`. You cannot use both `--git` and `--local-git`. You can use standard Git URLs like:
Install bundler-graph gem from Git repository. You can use standard Git URLs like:

`ssh://[user@]host.xz[:port]/path/to/repo.git`<br>
`http[s]://host.xz[:port]/path/to/repo.git`<br>
`/path/to/repo`<br>
`file:///path/to/repo`

When you specify `--git`/`--local-git`, you can use `--branch` or `--ref` to specify any branch, tag, or commit hash (revision) to use. When you specify both, only the latter is used.
When you specify `--git`, you can use `--branch` or `--ref` to specify any branch, tag, or commit hash (revision) to use. When you specify both, only the latter is used.

### uninstall

Expand Down
14 changes: 5 additions & 9 deletions bundler/lib/bundler/plugin/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ def install(names, options)

if options[:git]
install_git(names, version, options)
elsif options[:local_git]
install_local_git(names, version, options)
else
sources = options[:source] || Gem.sources
install_rubygems(names, version, sources)
Expand All @@ -45,6 +43,11 @@ def check_sources_consistency!(options)
if options.key?(:git) && options.key?(:local_git)
raise InvalidOption, "Remote and local plugin git sources can't be both specified"
end
# back-compat; local_git is an alias for git
if options.key?(:local_git)
Bundler::SharedHelpers.major_deprecation(2, "--local_git is deprecated, use --git")
options[:git] = options.delete(:local_git)
end
end

def install_git(names, version, options)
Expand All @@ -54,13 +57,6 @@ def install_git(names, version, options)
install_all_sources(names, version, options, options[:source])
end

def install_local_git(names, version, options)
uri = options.delete(:local_git)
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
#
Expand Down
6 changes: 3 additions & 3 deletions bundler/spec/bundler/plugin/installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
end

it "returns the installed spec after installing local git plugins" do
allow(installer).to receive(:install_local_git).
allow(installer).to receive(:install_git).
and_return("new-plugin" => spec)

expect(installer.install(["new-plugin"], local_git: "/phony/path/repo")).
expect(installer.install(["new-plugin"], git: "/phony/path/repo")).
to eq("new-plugin" => spec)
end

Expand Down Expand Up @@ -80,7 +80,7 @@
end

let(:result) do
installer.install(["ga-plugin"], local_git: lib_path("ga-plugin").to_s)
installer.install(["ga-plugin"], git: lib_path("ga-plugin").to_s)
end

it "returns the installed spec after installing" do
Expand Down
17 changes: 17 additions & 0 deletions bundler/spec/other/major_deprecation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,23 @@
pending "fails with a helpful message", bundler: "3"
end

context "bundle plugin install --local_git" do
before do
build_git "foo" do |s|
s.write "plugins.rb"
end
end

it "prints a deprecation warning", bundler: "< 3" do
bundle "plugin install foo --local_git #{lib_path("foo-1.0")}"

expect(out).to include("Installed plugin foo")
expect(deprecations).to include "--local_git is deprecated, use --git"
end

pending "fails with a helpful message", bundler: "3"
end

describe "deprecating rubocop", :readline do
context "bundle gem --rubocop" do
before do
Expand Down
4 changes: 2 additions & 2 deletions bundler/spec/plugins/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ def exec(command, args)
s.write "plugins.rb"
end

bundle "plugin install foo --local_git #{lib_path("foo-1.0")}"
bundle "plugin install foo --git #{lib_path("foo-1.0")}"

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 --local_git /phony/path/project --git git@gitphony.com:/repo/project", raise_on_error: false
bundle "plugin install foo --git /phony/path/project --git git@gitphony.com:/repo/project", raise_on_error: false

expect(exitstatus).not_to eq(0)
expect(err).to eq("Remote and local plugin git sources can't be both specified")
Expand Down

0 comments on commit 149b929

Please sign in to comment.