summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCody Cutrer <cody@instructure.com>2023-10-09 11:24:32 -0600
committergit <svn-admin@ruby-lang.org>2024-03-25 14:25:46 +0000
commit552647175e8319aa7cc117d418f35ed761fdb822 (patch)
tree68f8471973cd7c55e83eb42e64346f6a8cf2b132 /lib
parent65264b0dfb73a4162b638fa2c9cc0e99c66360e2 (diff)
[rubygems/rubygems] Improve validation of `bundle plugin install` options
Ensure only one source type is specified, and ensure options that are only relevant to git sources are only specified with git. https://github.com/rubygems/rubygems/commit/58b043215e
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/plugin/installer.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index 7ae56440fb..7267f58f5d 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -43,11 +43,24 @@ module Bundler
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
+
+ if (options.keys & [:source, :git]).length > 1
+ raise InvalidOption, "Only one of --source, or --git may be specified"
+ end
+
+ if (options.key?(:branch) || options.key?(:ref)) && !options.key?(:git)
+ raise InvalidOption, "--#{options.key?(:branch) ? "branch" : "ref"} can only be used with git sources"
+ end
+
+ if options.key?(:branch) && options.key?(:ref)
+ raise InvalidOption, "--branch and --ref can't be both specified"
+ end
end
def install_git(names, version, options)