Check for write access instead of HOMEBREW_DEVELOPER.
This commit is contained in:
parent
57fefff942
commit
68e0c5f904
@ -17,16 +17,17 @@ module Cask
|
||||
].freeze
|
||||
|
||||
def run
|
||||
raise "This command may only be run by Homebrew maintainers." unless ENV["HOMEBREW_DEVELOPER"]
|
||||
taps = OFFICIAL_CASK_TAPS.map(&Tap.public_method(:fetch))
|
||||
|
||||
access = taps.all? { |tap| GitHub.write_access?(tap.full_name) }
|
||||
raise "This command may only be run by Homebrew maintainers." unless access
|
||||
|
||||
Homebrew.install_gem! "git_diff"
|
||||
require "git_diff"
|
||||
|
||||
failed = []
|
||||
|
||||
OFFICIAL_CASK_TAPS.each do |tap_name|
|
||||
tap = Tap.fetch(tap_name)
|
||||
|
||||
taps.each do |tap|
|
||||
open_pull_requests = GitHub.pull_requests(tap.full_name, state: :open, base: "master")
|
||||
|
||||
open_pull_requests.each do |pr|
|
||||
|
||||
@ -274,6 +274,19 @@ module GitHub
|
||||
search_issues(name, state: "open", repo: "#{tap.user}/homebrew-#{tap.repo}", in: "title")
|
||||
end
|
||||
|
||||
def user
|
||||
@user ||= open_api("#{API_URL}/user")
|
||||
end
|
||||
|
||||
def permission(repo, user)
|
||||
open_api("#{API_URL}/repos/#{repo}/collaborators/#{user}/permission")
|
||||
end
|
||||
|
||||
def write_access?(repo, user = nil)
|
||||
user ||= self.user["login"]
|
||||
["admin", "write"].include?(permission(repo, user)["permission"])
|
||||
end
|
||||
|
||||
def pull_requests(repo, base:, state: :open, **_options)
|
||||
url = "#{API_URL}/repos/#{repo}/pulls?#{URI.encode_www_form(base: base, state: state)}"
|
||||
open_api(url)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user