aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorMike McQuaid2017-04-23 18:56:22 +0100
committerMike McQuaid2017-04-23 18:56:22 +0100
commitd5155256ce34595a72676d0ced9fa866d778b96c (patch)
tree967013e7bae9ef578a6dea27bea05e7c7a5591ea /Library/Homebrew/utils.rb
parentf3dc06a4e7e81304b335bd0f34ef748b9d1a35a6 (diff)
downloadbrew-d5155256ce34595a72676d0ced9fa866d778b96c.tar.bz2
Fix audit version_scheme and revision checks.
Another attempt at fixing `brew audit` issues around detecting `revision` and `version_scheme` changes correctly. First done in #1754 and #2086 (reverted in #2099 and #2100). To ease future debugging a `ph` helper has been added to print a hash and a series of RSpec tests to verify that the `revision`, `version_scheme` and `version` formula version audits behave as expected. Fixes #1731.
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 0ecc06d2a..82bc38895 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -517,3 +517,19 @@ def migrate_legacy_keg_symlinks_if_necessary
end
FileUtils.rm_rf legacy_pinned_kegs
end
+
+def puts_hash(hash, indent: 0)
+ return hash unless hash.is_a? Hash
+ hash.each do |key, value|
+ indent_spaces = " " * (indent * 2)
+ printf "#{indent_spaces}#{key}:"
+ if value.is_a? Hash
+ puts
+ puts_hash(value, indent: indent+1)
+ else
+ puts " #{value}"
+ end
+ end
+ hash
+end
+alias ph puts_hash