-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Introduce install_or_cli_help and use it default bundle command
#9136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+51
−20
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
628e0ed
Restore `install` as default command
byroot f3f505c
Print help summary when the default command fail
byroot 9e44b5e
Add informational message when default_cli_command is unset.
hsbt 69ac3ae
Added vendored thor change to automatiek patch
hsbt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -120,20 +120,28 @@ def cli_help | |||||
| self.class.send(:class_options_help, shell) | ||||||
| end | ||||||
|
|
||||||
| desc "install_or_cli_help", "Tries to run bundle install but prints a summary of bundler commands if there is no Gemfile", hide: true | ||||||
| def install_or_cli_help | ||||||
| invoke_other_command("install") | ||||||
| rescue GemfileNotFound => error | ||||||
| Bundler.ui.error error.message, wrap: true | ||||||
| invoke_other_command("cli_help") | ||||||
| end | ||||||
|
|
||||||
| def self.default_command(meth = nil) | ||||||
| return super if meth | ||||||
|
|
||||||
| default_cli_command = Bundler.settings[:default_cli_command] | ||||||
| return default_cli_command if default_cli_command | ||||||
|
|
||||||
| Bundler.ui.warn(<<~MSG) | ||||||
| In the next version of Bundler, running `bundle` without argument will no longer run `bundle install`. | ||||||
| Instead, the `help` command will be displayed. | ||||||
|
|
||||||
| If you'd like to keep the previous behaviour please run `bundle config set default_cli_command install --global`. | ||||||
| MSG | ||||||
| unless Bundler.settings[:default_cli_command] | ||||||
| Bundler.ui.info <<-MSG | ||||||
| In the feature version of Bundler, running `bundle` without argument will no longer run `bundle install`. | ||||||
| Instead, the `cli_help` command will be displayed. Please use `bundle install` explicitly for scripts like CI/CD. | ||||||
| If you wish to use feature behavior now with `bundle config set default_cli_command cli_help --global` | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| or you can continue to use the old behavior with `bundle config set default_cli_command install_or_cli_help --global`. | ||||||
| This message will be removed after a default_cli_command value is set. | ||||||
| MSG | ||||||
| end | ||||||
|
|
||||||
| "install" | ||||||
| Bundler.settings[:default_cli_command] || "install_or_cli_help" | ||||||
| end | ||||||
|
|
||||||
| class_option "no-color", type: :boolean, desc: "Disable colorization in output" | ||||||
|
|
@@ -723,6 +731,19 @@ def current_command | |||||
| config[:current_command] | ||||||
| end | ||||||
|
|
||||||
| def invoke_other_command(name) | ||||||
| _, _, config = @_initializer | ||||||
| original_command = config[:current_command] | ||||||
| command = self.class.all_commands[name] | ||||||
| config[:current_command] = command | ||||||
| send(name) | ||||||
| ensure | ||||||
| config[:current_command] = original_command | ||||||
|
|
||||||
| end | ||||||
|
|
||||||
| def current_command=(command) | ||||||
| end | ||||||
|
|
||||||
| def print_command | ||||||
| return unless Bundler.ui.debug? | ||||||
| cmd = current_command | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.