Skip to content
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

cmd/prof: raise error when cmd is bash file #10280

Merged

Conversation

hyuraku
Copy link
Contributor

@hyuraku hyuraku commented Jan 10, 2021

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?
  • Have you successfully run brew man locally and committed any changes?

brew prof update caused an error because update is made by bash, not ruby. However, the error message Error: Unknown command: update was not correct, so I added the correct message.

brew prof update
Error: Unknown command: update
Error: Failure while executing; `/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/local/Homebrew/Library/Homebrew/brew.rb update` exited with 1.

@hyuraku hyuraku changed the title cmd/commands: add_only_bash_command_list cmd/commands: add only bash command list Jan 10, 2021
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hyuraku! some comments.

@@ -197,4 +197,8 @@ def rebuild_commands_completion_list
file = HOMEBREW_CACHE/"all_commands_list.txt"
file.atomic_write("#{commands(aliases: true).sort.join("\n")}\n")
end

def only_bash_command_list
internal_commands.reject { |cmd| valid_internal_cmd?(cmd) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function makes sense but not the implementation. This should check for a file extension instead.

@@ -131,6 +131,8 @@ class MissingEnvironmentVariables < RuntimeError; end
end
exec "brew-#{cmd}", *ARGV
else
raise "command made by bash not ruby: #{cmd}" if Commands.only_bash_command_list.include?(cmd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like this should be in brew.rb but prof.rb instead.

@hyuraku hyuraku changed the title cmd/commands: add only bash command list cmd/prof: raise error when cmd is bash file Jan 11, 2021
@@ -26,6 +26,8 @@ def prof

brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
FileUtils.mkdir_p "prof"
cmd = args.named.first
raise "#{cmd} is made by bash not ruby" if Commands.path(cmd).extname == ".sh"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise "#{cmd} is made by bash not ruby" if Commands.path(cmd).extname == ".sh"
raise UsageError, "#{cmd} is a Bash command!" if Commands.path(cmd).extname == ".sh"

@hyuraku hyuraku force-pushed the cmd/commands_add_only_bash_command_list branch from 76f1a7c to c56fff3 Compare January 11, 2021 12:02
@hyuraku
Copy link
Contributor Author

hyuraku commented Jan 17, 2021

@MikeMcQuaid
Could you review this PR again?

@MikeMcQuaid
Copy link
Member

Thanks again @hyuraku!

@MikeMcQuaid MikeMcQuaid merged commit 668073d into Homebrew:master Jan 18, 2021
@hyuraku hyuraku deleted the cmd/commands_add_only_bash_command_list branch January 18, 2021 14:29
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Feb 18, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Feb 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants