From 3657700c4069ffd5d9e9b900e75f484f80eb8e3f Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Tue, 6 Sep 2022 07:37:50 +0000 Subject: [ruby/rubygems] Bundler: validate more options for add sub-command Signed-off-by: Takuya Noguchi https://github.com/ruby/rubygems/commit/6ca2e28680 --- lib/bundler/cli/add.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb index 12a681a816..9f17604096 100644 --- a/lib/bundler/cli/add.rb +++ b/lib/bundler/cli/add.rb @@ -36,6 +36,16 @@ module Bundler end def validate_options! + raise InvalidOption, "You cannot specify `--git` and `--github` at the same time." if options["git"] && options["github"] + + unless options["git"] || options["github"] + raise InvalidOption, "You cannot specify `--branch` unless `--git` or `--github` is specified." if options["branch"] + + raise InvalidOption, "You cannot specify `--ref` unless `--git` or `--github` is specified." if options["ref"] + end + + raise InvalidOption, "You cannot specify `--branch` and `--ref` at the same time." if options["branch"] && options["ref"] + raise InvalidOption, "You cannot specify `--strict` and `--optimistic` at the same time." if options[:strict] && options[:optimistic] # raise error when no gems are specified -- cgit v1.2.3