Merge pull request #16754 from Homebrew/look-for-licenses-not-always-on-the-default-branch
formula_audit: Check the license(s) of the specific release
This commit is contained in:
commit
0afede389f
@ -255,7 +255,8 @@ module Homebrew
|
||||
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*})
|
||||
return if user.blank?
|
||||
|
||||
github_license = GitHub.get_repo_license(user, repo)
|
||||
tag = SharedAudits.github_tag_from_url(formula.stable.url)
|
||||
github_license = GitHub.get_repo_license(user, repo, ref: tag)
|
||||
return unless github_license
|
||||
return if (licenses + ["NOASSERTION"]).include?(github_license)
|
||||
return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| licenses.include? license }
|
||||
|
||||
@ -497,8 +497,10 @@ module GitHub
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_repo_license(user, repo)
|
||||
response = API.open_rest("#{API_URL}/repos/#{user}/#{repo}/license")
|
||||
def self.get_repo_license(user, repo, ref: nil)
|
||||
url = "#{API_URL}/repos/#{user}/#{repo}/license"
|
||||
url += "?ref=#{ref}" if ref.present?
|
||||
response = API.open_rest(url)
|
||||
return unless response.key?("license")
|
||||
|
||||
response["license"]["spdx_id"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user