Skip to content

Commit

Permalink
sponsors-maintainers-man-completions: various fixes.
Browse files Browse the repository at this point in the history
- fix name
- use correct command
  • Loading branch information
MikeMcQuaid committed Sep 8, 2022
1 parent 04dfb9d commit 8aa16e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sponsors-maintainers-man-completions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems-

- name: Update maintainers, manpage and completions
- name: Update sponsors, maintainers, manpage and completions
id: update
run: |
git fetch origin
Expand All @@ -69,7 +69,7 @@ jobs:
git checkout --no-track -B "${BRANCH}" origin/master
fi
if brew sponsors
if brew update-sponsors --debug
then
git add "${GITHUB_WORKSPACE}/README.md"
git commit -m "Update sponsors." \
Expand Down
5 changes: 4 additions & 1 deletion Library/Homebrew/dev-cmd/update-sponsors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ def update_sponsors

named_sponsors = []
logo_sponsors = []
largest_monthly_amount = 0

GitHub.sponsorships("Homebrew").each do |s|
largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].compact.max
largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].max
named_sponsors << "[#{sponsor_name(s)}](#{sponsor_url(s)})" if largest_monthly_amount >= NAMED_MONTHLY_AMOUNT

next if largest_monthly_amount < URL_MONTHLY_AMOUNT

logo_sponsors << "[![#{sponsor_name(s)}](#{sponsor_logo(s)})](#{sponsor_url(s)})"
end

odie "No sponsorships amounts found! Ensure you have sufficient permissions!" if largest_monthly_amount.zero?

named_sponsors << "many other users and organisations via [GitHub Sponsors](https://github.com/sponsors/Homebrew)"

readme = HOMEBREW_REPOSITORY/"README.md"
Expand Down
13 changes: 8 additions & 5 deletions Library/Homebrew/utils/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ def sponsorships(user)
current_sponsorships = result["data"]["organization"]["sponsorshipsAsMaintainer"]

# The organisations mentioned above will show up as nil nodes.
sponsorships += current_sponsorships["nodes"].compact
if (nodes = current_sponsorships["nodes"].compact.presence)
sponsorships += nodes
end

if (page_info = current_sponsorships["pageInfo"].presence) &&
page_info["hasNextPage"].presence
Expand All @@ -460,16 +462,17 @@ def sponsorships(user)
end

sponsorships.map do |sponsorship|
closest_tier_monthly_amount = sponsorship["tier"].fetch("closestLesserValueTier", nil)
&.fetch("monthlyPriceInDollars", nil)
monthly_amount = sponsorship["tier"]["monthlyPriceInDollars"]
sponsor = sponsorship["sponsorEntity"]
tier = sponsorship["tier"].presence || {}
monthly_amount = tier["monthlyPriceInDollars"].presence || 0
closest_tier = tier["closestLesserValueTier"].presence || {}
closest_tier_monthly_amount = closest_tier["monthlyPriceInDollars"].presence || 0

{
name: sponsor["name"].presence || sponsor["login"],
login: sponsor["login"],
monthly_amount: monthly_amount,
closest_tier_monthly_amount: closest_tier_monthly_amount || 0,
closest_tier_monthly_amount: closest_tier_monthly_amount,
}
end
end
Expand Down

0 comments on commit 8aa16e8

Please sign in to comment.