-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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/info: show size information #18172
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -45,6 +45,8 @@ | |||||
switch "--github", | ||||||
description: "Open the GitHub source page for <formula> and <cask> in a browser. " \ | ||||||
"To view the history locally: `brew log -p` <formula> or <cask>" | ||||||
switch "--github-manifest", | ||||||
description: "Fetch Github package manifest for extra information when <formula> is not installed." | ||||||
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
|
||||||
flag "--json", | ||||||
description: "Print a JSON representation. Currently the default value for <version> is `v1` for " \ | ||||||
"<formula>. For <formula> and <cask> use `v2`. See the docs for examples of using the " \ | ||||||
|
@@ -303,6 +305,17 @@ | |||||
] | ||||||
if kegs.empty? | ||||||
puts "Not installed" | ||||||
if args.github_manifest? && !(bottle = formula.bottle).nil? | ||||||
begin | ||||||
bottle.fetch_tab(quiet: !args.debug?) | ||||||
bottle_size = bottle.bottle_size | ||||||
puts "Bottle size: #{disk_usage_readable(bottle_size)}" if bottle_size.positive? | ||||||
installed_size = bottle.installed_size | ||||||
puts "Installed size: #{disk_usage_readable(installed_size)}" if installed_size.positive? | ||||||
Comment on lines
+311
to
+314
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. Currently looks like
For comparison
Also, mainly an approximate if pouring bottle into non-standard prefix. |
||||||
rescue RuntimeError => e | ||||||
odebug e | ||||||
end | ||||||
end | ||||||
else | ||||||
puts "Installed" | ||||||
kegs.each do |keg| | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -140,7 +140,7 @@ | |||||||||
Partial.new(self, files) | ||||||||||
end | ||||||||||
|
||||||||||
def fetch(verify_download_integrity: true) | ||||||||||
def fetch(verify_download_integrity: true, quiet: false) | ||||||||||
fetch_patches | ||||||||||
|
||||||||||
super | ||||||||||
|
@@ -286,6 +286,27 @@ | |||||||||
end | ||||||||||
|
||||||||||
def tab | ||||||||||
tab = manifest_annotations["sh.brew.tab"] | ||||||||||
raise Error, "Couldn't find tab from manifest." if tab.blank? | ||||||||||
|
||||||||||
begin | ||||||||||
JSON.parse(tab) | ||||||||||
rescue JSON::ParserError | ||||||||||
raise Error, "Couldn't parse tab JSON." | ||||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
def bottle_size | ||||||||||
manifest_annotations["sh.brew.bottle.size"].to_i | ||||||||||
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
Suggested change
depending on whether |
||||||||||
end | ||||||||||
|
||||||||||
def installed_size | ||||||||||
manifest_annotations["sh.brew.bottle.installed_size"].to_i | ||||||||||
end | ||||||||||
|
||||||||||
private | ||||||||||
|
||||||||||
def manifest_annotations | ||||||||||
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. Is this safe to cache? 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. Think so? |
||||||||||
json = begin | ||||||||||
JSON.parse(cached_download.read) | ||||||||||
rescue JSON::ParserError | ||||||||||
|
@@ -308,14 +329,7 @@ | |||||||||
end | ||||||||||
raise Error, "Couldn't find manifest matching bottle checksum." if manifest_annotations.blank? | ||||||||||
|
||||||||||
tab = manifest_annotations["sh.brew.tab"] | ||||||||||
raise Error, "Couldn't find tab from manifest." if tab.blank? | ||||||||||
|
||||||||||
begin | ||||||||||
JSON.parse(tab) | ||||||||||
rescue JSON::ParserError | ||||||||||
raise Error, "Couldn't parse tab JSON." | ||||||||||
end | ||||||||||
manifest_annotations | ||||||||||
end | ||||||||||
end | ||||||||||
|
||||||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Does this work with --json?
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.
Not yet. Haven't had time to look at that code path. Also need to figure out the path to get information to formulae.brew.sh, which may be similar.
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.
Yeh, it's that code path. If it doesn't work for now: might be worth marking as conflicting?