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

Warn developers when uninstalling a dependency #1498

Merged
merged 4 commits into from
Nov 15, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
uninstall: style fixes
Works around Rubycop not liking method names that start with `is_`
by changing convention from singular to plural.

I think it's better that way anyway.
  • Loading branch information
alyssais committed Nov 14, 2016
commit ca3562645c30b86da5057cf2f8de9974c4a18413
14 changes: 7 additions & 7 deletions Library/Homebrew/cmd/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def check_for_dependents(kegs)
end

class DependentsMessage
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Put all the shared stuff between the two messages into a class so it can be re-used between both of them. It's a bit longer, but I think much cleaner now.

attr :reqs, :deps
attr_reader :reqs, :deps

def initialize(requireds, dependents)
@reqs = requireds
Expand All @@ -105,11 +105,11 @@ def initialize(requireds, dependents)

protected

def is(items)
def are(items)
items.count == 1 ? "is" : "are"
end

def it(items)
def they(items)
items.count == 1 ? "it" : "they"
end

Expand All @@ -121,15 +121,15 @@ def sample_command
"brew uninstall --ignore-dependencies #{list reqs.map(&:name)}"
end

def is_required_by_deps
"#{is reqs} required by #{list deps}, which #{is deps} currently installed"
def are_required_by_deps
"#{are reqs} required by #{list deps}, which #{are deps} currently installed"
end
end

class DeveloperDependentsMessage < DependentsMessage
def output
opoo <<-EOS.undent
#{list reqs} #{is_required_by_deps}.
#{list reqs} #{are_required_by_deps}.
You can silence this warning with:
#{sample_command}
EOS
Expand All @@ -140,7 +140,7 @@ class NondeveloperDependentsMessage < DependentsMessage
def output
ofail <<-EOS.undent
Refusing to uninstall #{list reqs}
because #{it reqs} #{is_required_by_deps}.
because #{they reqs} #{are_required_by_deps}.
You can override this and force removal with:
#{sample_command}
EOS
Expand Down