update-license-data: fix latest_tag error

Add latest_tag method to utils/spdx
This commit is contained in:
Seeker 2020-08-10 11:32:05 -07:00
parent deea71b1d0
commit f345f554c8
2 changed files with 5 additions and 2 deletions

View File

@ -35,6 +35,6 @@ module Homebrew
ohai "git add" ohai "git add"
safe_system "git", "add", SPDX::JSON_PATH safe_system "git", "add", SPDX::JSON_PATH
ohai "git commit" ohai "git commit"
system "git", "commit", "--message", "data/spdx.json: update to #{latest_tag}" system "git", "commit", "--message", "data/spdx.json: update to #{SPDX.latest_tag}"
end end
end end

View File

@ -12,8 +12,11 @@ module SPDX
@spdx_data ||= JSON.parse(JSON_PATH.read) @spdx_data ||= JSON.parse(JSON_PATH.read)
end end
def latest_tag
@latest_tag ||= GitHub.open_api(API_URL)["tag_name"]
end
def download_latest_license_data!(to: JSON_PATH) def download_latest_license_data!(to: JSON_PATH)
latest_tag = GitHub.open_api(API_URL)["tag_name"]
data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json" data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json"
curl_download(data_url, to: to, partial: false) curl_download(data_url, to: to, partial: false)
end end