Merge pull request #10615 from jonchang/enhance-sponsors
Update Github sponsor text and logos
This commit is contained in:
commit
a946cde4e1
@ -13,51 +13,61 @@ module Homebrew
|
||||
def sponsors_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
description <<~EOS
|
||||
Print a Markdown summary of Homebrew's GitHub Sponsors, suitable for pasting into a README.
|
||||
Update the list of GitHub Sponsors in the `Homebrew/brew` README.
|
||||
EOS
|
||||
|
||||
named_args :none
|
||||
end
|
||||
end
|
||||
|
||||
def sponsor_name(s)
|
||||
s["name"] || s["login"]
|
||||
end
|
||||
|
||||
def sponsor_logo(s)
|
||||
"https://github.com/#{s["login"]}.png?size=64"
|
||||
end
|
||||
|
||||
def sponsor_url(s)
|
||||
"https://github.com/#{s["login"]}"
|
||||
end
|
||||
|
||||
def sponsors
|
||||
sponsors_args.parse
|
||||
|
||||
sponsors = {
|
||||
"named" => [],
|
||||
"users" => 0,
|
||||
"orgs" => 0,
|
||||
}
|
||||
named_sponsors = []
|
||||
logo_sponsors = []
|
||||
|
||||
GitHub.sponsors_by_tier("Homebrew").each do |tier|
|
||||
sponsors["named"] += tier["sponsors"] if tier["tier"] >= 100
|
||||
sponsors["users"] += tier["count"]
|
||||
sponsors["orgs"] += tier["sponsors"].count { |s| s["type"] == "organization" }
|
||||
if tier["tier"] >= 100
|
||||
named_sponsors += tier["sponsors"].map do |s|
|
||||
"[#{sponsor_name(s)}](#{sponsor_url(s)})"
|
||||
end
|
||||
end
|
||||
|
||||
next unless tier["tier"] >= 1000
|
||||
|
||||
logo_sponsors += tier["sponsors"].map do |s|
|
||||
"[})](#{sponsor_url(s)})"
|
||||
end
|
||||
end
|
||||
|
||||
items = []
|
||||
items += sponsors["named"].map { |s| "[#{s["name"]}](https://github.com/#{s["login"]})" }
|
||||
named_sponsors << "many other users and organisations via [GitHub Sponsors](https://github.com/sponsors/Homebrew)"
|
||||
|
||||
anon_users = sponsors["users"] - sponsors["named"].length - sponsors["orgs"]
|
||||
readme = HOMEBREW_REPOSITORY/"README.md"
|
||||
content = readme.read
|
||||
content.gsub!(/(Homebrew is generously supported by) .*\Z/m, "\\1 #{named_sponsors.to_sentence}.\n")
|
||||
content << "\n#{logo_sponsors.join}\n" if logo_sponsors.presence
|
||||
|
||||
items << if items.length > 1
|
||||
"#{anon_users} other users"
|
||||
File.open(readme, "w+") { |f| f.write(content) }
|
||||
|
||||
diff = system_command "git", args: [
|
||||
"-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", "README.md"
|
||||
]
|
||||
if diff.status.success?
|
||||
puts "No changes to list of sponsors."
|
||||
else
|
||||
"#{anon_users} users"
|
||||
puts "List of sponsors updated in the README."
|
||||
end
|
||||
|
||||
if sponsors["orgs"] == 1
|
||||
items << "#{sponsors["orgs"]} organization"
|
||||
elsif sponsors["orgs"] > 1
|
||||
items << "#{sponsors["orgs"]} organizations"
|
||||
end
|
||||
|
||||
sponsor_text = if items.length > 2
|
||||
items[0..-2].join(", ") + " and #{items.last}"
|
||||
else
|
||||
items.join(" and ")
|
||||
end
|
||||
|
||||
puts "Homebrew is generously supported by #{sponsor_text} via [GitHub Sponsors](https://github.com/sponsors/Homebrew)."
|
||||
end
|
||||
end
|
||||
|
@ -87,4 +87,6 @@ Homebrew is a member of the [Software Freedom Conservancy](https://sfconservancy
|
||||
|
||||
[](https://sfconservancy.org)
|
||||
|
||||
Homebrew is generously supported by [Randy Reddig](https://github.com/ydnar) and 439 other users via [GitHub Sponsors](https://github.com/sponsors/Homebrew).
|
||||
Homebrew is generously supported by [Substack](https://github.com/substackinc), [Randy Reddig](https://github.com/ydnar), [embark-studios](https://github.com/embark-studios) and many other users and organisations via [GitHub Sponsors](https://github.com/sponsors/Homebrew).
|
||||
|
||||
[](https://github.com/substackinc)
|
||||
|
@ -1225,7 +1225,7 @@ __fish_brew_complete_arg 'sh' -l quiet -d 'Make some output more quiet'
|
||||
__fish_brew_complete_arg 'sh' -l verbose -d 'Make some output more verbose'
|
||||
|
||||
|
||||
__fish_brew_complete_cmd 'sponsors' 'Print a Markdown summary of Homebrew\'s GitHub Sponsors, suitable for pasting into a README'
|
||||
__fish_brew_complete_cmd 'sponsors' 'Update the list of GitHub Sponsors in the `Homebrew/brew` README'
|
||||
__fish_brew_complete_arg 'sponsors' -l debug -d 'Display any debugging information'
|
||||
__fish_brew_complete_arg 'sponsors' -l help -d 'Show this message'
|
||||
__fish_brew_complete_arg 'sponsors' -l quiet -d 'Make some output more quiet'
|
||||
|
@ -196,7 +196,7 @@ __brew_internal_commands() {
|
||||
'search:Perform a substring search of cask tokens and formula names for text'
|
||||
'sh:Enter an interactive shell for Homebrew'\''s build environment'
|
||||
'shellenv:Print export statements'
|
||||
'sponsors:Print a Markdown summary of Homebrew'\''s GitHub Sponsors, suitable for pasting into a README'
|
||||
'sponsors:Update the list of GitHub Sponsors in the `Homebrew/brew` README'
|
||||
'style:Check formulae or files for conformance to Homebrew style guidelines'
|
||||
'tap:Tap a formula repository'
|
||||
'tap-info:Show detailed information about one or more taps'
|
||||
|
@ -1259,7 +1259,7 @@ which build systems would not find otherwise.
|
||||
|
||||
### `sponsors`
|
||||
|
||||
Print a Markdown summary of Homebrew's GitHub Sponsors, suitable for pasting into a README.
|
||||
Update the list of GitHub Sponsors in the `Homebrew/brew` README.
|
||||
|
||||
### `style` [*`options`*] [*`file`*|*`tap`*|*`formula`*|*`cask`* ...]
|
||||
|
||||
|
@ -1737,7 +1737,7 @@ Use the standard \fBPATH\fR instead of superenv\'s when \fBstd\fR is passed\.
|
||||
Execute commands in a non\-interactive shell\.
|
||||
.
|
||||
.SS "\fBsponsors\fR"
|
||||
Print a Markdown summary of Homebrew\'s GitHub Sponsors, suitable for pasting into a README\.
|
||||
Update the list of GitHub Sponsors in the \fBHomebrew/brew\fR README\.
|
||||
.
|
||||
.SS "\fBstyle\fR [\fIoptions\fR] [\fIfile\fR|\fItap\fR|\fIformula\fR|\fIcask\fR \.\.\.]"
|
||||
Check formulae or files for conformance to Homebrew style guidelines\.
|
||||
|
Loading…
x
Reference in New Issue
Block a user