Skip to content
Snippets Groups Projects
Unverified Commit a946cde4 authored by Jonathan Chang's avatar Jonathan Chang Committed by GitHub
Browse files

Merge pull request #10615 from jonchang/enhance-sponsors

Update Github sponsor text and logos
parents 2d406105 1d4597d1
No related branches found
No related tags found
No related merge requests found
......@@ -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" }
end
if tier["tier"] >= 100
named_sponsors += tier["sponsors"].map do |s|
"[#{sponsor_name(s)}](#{sponsor_url(s)})"
end
end
items = []
items += sponsors["named"].map { |s| "[#{s["name"]}](https://github.com/#{s["login"]})" }
next unless tier["tier"] >= 1000
anon_users = sponsors["users"] - sponsors["named"].length - sponsors["orgs"]
items << if items.length > 1
"#{anon_users} other users"
else
"#{anon_users} users"
logo_sponsors += tier["sponsors"].map do |s|
"[![#{sponsor_name(s)}](#{sponsor_logo(s)})](#{sponsor_url(s)})"
end
end
if sponsors["orgs"] == 1
items << "#{sponsors["orgs"]} organization"
elsif sponsors["orgs"] > 1
items << "#{sponsors["orgs"]} organizations"
end
named_sponsors << "many other users and organisations via [GitHub Sponsors](https://github.com/sponsors/Homebrew)"
sponsor_text = if items.length > 2
items[0..-2].join(", ") + " and #{items.last}"
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
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
items.join(" and ")
puts "List of sponsors updated in the README."
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
[![Software Freedom Conservancy](https://sfconservancy.org/img/conservancy_64x64.png)](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).
[![Substack](https://github.com/substackinc.png?size=64)](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\.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment