Merge pull request #11931 from carlocab/cleanup-formulae
cleanup: allow users to specify formulae to skip cleaning
This commit is contained in:
commit
430bd71a56
@ -160,11 +160,18 @@ module Homebrew
|
|||||||
cleanup = Cleanup.new
|
cleanup = Cleanup.new
|
||||||
if cleanup.periodic_clean_due?
|
if cleanup.periodic_clean_due?
|
||||||
cleanup.periodic_clean!
|
cleanup.periodic_clean!
|
||||||
elsif f.latest_version_installed?
|
elsif f.latest_version_installed? && !cleanup.skip_clean_formula?(f)
|
||||||
cleanup.cleanup_formula(f)
|
cleanup.cleanup_formula(f)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def skip_clean_formula?(f)
|
||||||
|
return false if Homebrew::EnvConfig.no_cleanup_formulae.blank?
|
||||||
|
|
||||||
|
skip_clean_formulae = Homebrew::EnvConfig.no_cleanup_formulae.split(",")
|
||||||
|
skip_clean_formulae.include?(f.name) || (skip_clean_formulae & f.aliases).present?
|
||||||
|
end
|
||||||
|
|
||||||
def periodic_clean_due?
|
def periodic_clean_due?
|
||||||
return false if Homebrew::EnvConfig.no_install_cleanup?
|
return false if Homebrew::EnvConfig.no_install_cleanup?
|
||||||
|
|
||||||
@ -186,7 +193,10 @@ module Homebrew
|
|||||||
|
|
||||||
def clean!(quiet: false, periodic: false)
|
def clean!(quiet: false, periodic: false)
|
||||||
if args.empty?
|
if args.empty?
|
||||||
Formula.installed.sort_by(&:name).each do |formula|
|
Formula.installed
|
||||||
|
.sort_by(&:name)
|
||||||
|
.reject { |f| skip_clean_formula?(f) }
|
||||||
|
.each do |formula|
|
||||||
cleanup_formula(formula, quiet: quiet, ds_store: false, cache_db: false)
|
cleanup_formula(formula, quiet: quiet, ds_store: false, cache_db: false)
|
||||||
end
|
end
|
||||||
cleanup_cache
|
cleanup_cache
|
||||||
@ -223,7 +233,12 @@ module Homebrew
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
cleanup_formula(formula) if formula
|
if formula && skip_clean_formula?(formula)
|
||||||
|
onoe "Refusing to clean #{formula} because it is listed in " \
|
||||||
|
"#{Tty.bold}HOMEBREW_NO_CLEANUP_FORMULAE#{Tty.reset}!"
|
||||||
|
elsif formula
|
||||||
|
cleanup_formula(formula)
|
||||||
|
end
|
||||||
cleanup_cask(cask) if cask
|
cleanup_cask(cask) if cask
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -229,6 +229,10 @@ module Homebrew
|
|||||||
"formulae.",
|
"formulae.",
|
||||||
boolean: true,
|
boolean: true,
|
||||||
},
|
},
|
||||||
|
HOMEBREW_NO_CLEANUP_FORMULAE: {
|
||||||
|
description: "A comma-separated list of formulae. Homebrew will refuse to clean up a " \
|
||||||
|
"formula if it appears on this list.",
|
||||||
|
},
|
||||||
HOMEBREW_NO_COLOR: {
|
HOMEBREW_NO_COLOR: {
|
||||||
description: "If set, do not print text with colour added.",
|
description: "If set, do not print text with colour added.",
|
||||||
default_text: "`$NO_COLOR`.",
|
default_text: "`$NO_COLOR`.",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user