Finish renaming GithubRelease to GithubReleases
This commit is contained in:
parent
940b63cad3
commit
104d30d231
@ -43,7 +43,7 @@ Style/Documentation:
|
|||||||
- livecheck/strategy/extract_plist.rb
|
- livecheck/strategy/extract_plist.rb
|
||||||
- livecheck/strategy/git.rb
|
- livecheck/strategy/git.rb
|
||||||
- livecheck/strategy/github_latest.rb
|
- livecheck/strategy/github_latest.rb
|
||||||
- livecheck/strategy/github_release.rb
|
- livecheck/strategy/github_releases.rb
|
||||||
- livecheck/strategy/gnome.rb
|
- livecheck/strategy/gnome.rb
|
||||||
- livecheck/strategy/gnu.rb
|
- livecheck/strategy/gnu.rb
|
||||||
- livecheck/strategy/hackage.rb
|
- livecheck/strategy/hackage.rb
|
||||||
|
|||||||
@ -270,7 +270,7 @@ require_relative "strategy/electron_builder"
|
|||||||
require_relative "strategy/extract_plist"
|
require_relative "strategy/extract_plist"
|
||||||
require_relative "strategy/git"
|
require_relative "strategy/git"
|
||||||
require_relative "strategy/github_latest"
|
require_relative "strategy/github_latest"
|
||||||
require_relative "strategy/github_release"
|
require_relative "strategy/github_releases"
|
||||||
require_relative "strategy/gnome"
|
require_relative "strategy/gnome"
|
||||||
require_relative "strategy/gnu"
|
require_relative "strategy/gnu"
|
||||||
require_relative "strategy/hackage"
|
require_relative "strategy/hackage"
|
||||||
|
|||||||
@ -41,7 +41,7 @@ module Homebrew
|
|||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
sig { params(url: String).returns(T::Boolean) }
|
sig { params(url: String).returns(T::Boolean) }
|
||||||
def self.match?(url)
|
def self.match?(url)
|
||||||
GitHubReleases.match?(url)
|
GithubReleases.match?(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extracts information from a provided URL and uses it to generate
|
# Extracts information from a provided URL and uses it to generate
|
||||||
@ -55,7 +55,7 @@ module Homebrew
|
|||||||
def self.generate_input_values(url)
|
def self.generate_input_values(url)
|
||||||
values = {}
|
values = {}
|
||||||
|
|
||||||
match = url.delete_suffix(".git").match(GitHubReleases::URL_MATCH_REGEX)
|
match = url.delete_suffix(".git").match(GithubReleases::URL_MATCH_REGEX)
|
||||||
return values if match.blank?
|
return values if match.blank?
|
||||||
|
|
||||||
values[:url] = "https://api.github.com/repos/#{match[:username]}/#{match[:repository]}/releases/latest"
|
values[:url] = "https://api.github.com/repos/#{match[:username]}/#{match[:repository]}/releases/latest"
|
||||||
@ -79,7 +79,7 @@ module Homebrew
|
|||||||
block: T.nilable(Proc),
|
block: T.nilable(Proc),
|
||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
def self.find_versions(url:, regex: GitHubReleases::DEFAULT_REGEX, **_unused, &block)
|
def self.find_versions(url:, regex: GithubReleases::DEFAULT_REGEX, **_unused, &block)
|
||||||
match_data = { matches: {}, regex: regex, url: url }
|
match_data = { matches: {}, regex: regex, url: url }
|
||||||
|
|
||||||
generated = generate_input_values(url)
|
generated = generate_input_values(url)
|
||||||
@ -88,7 +88,7 @@ module Homebrew
|
|||||||
match_data[:url] = generated[:url]
|
match_data[:url] = generated[:url]
|
||||||
|
|
||||||
release = GitHub.get_latest_release(generated[:username], generated[:repository])
|
release = GitHub.get_latest_release(generated[:username], generated[:repository])
|
||||||
GitHubReleases.versions_from_content(release, regex, &block).each do |match_text|
|
GithubReleases.versions_from_content(release, regex, &block).each do |match_text|
|
||||||
match_data[:matches][match_text] = Version.new(match_text)
|
match_data[:matches][match_text] = Version.new(match_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ module Homebrew
|
|||||||
# releases for suitable versions and the strategy is necessary or
|
# releases for suitable versions and the strategy is necessary or
|
||||||
# appropriate (e.g. the formula/cask uses a release asset and the
|
# appropriate (e.g. the formula/cask uses a release asset and the
|
||||||
# {GithubLatest} strategy isn't sufficient to identify the newest version.
|
# {GithubLatest} strategy isn't sufficient to identify the newest version.
|
||||||
# The strategy can only be applied by using `strategy :github_release`
|
# The strategy can only be applied by using `strategy :github_releases`
|
||||||
# in a `livecheck` block.
|
# in a `livecheck` block.
|
||||||
#
|
#
|
||||||
# The default regex identifies versions like `1.2.3`/`v1.2.3` in each
|
# The default regex identifies versions like `1.2.3`/`v1.2.3` in each
|
||||||
@ -33,7 +33,7 @@ module Homebrew
|
|||||||
|
|
||||||
# A priority of zero causes livecheck to skip the strategy. We do this
|
# A priority of zero causes livecheck to skip the strategy. We do this
|
||||||
# for {GithubReleases} so we can selectively apply the strategy using
|
# for {GithubReleases} so we can selectively apply the strategy using
|
||||||
# `strategy :github_release` in a `livecheck` block.
|
# `strategy :github_releases` in a `livecheck` block.
|
||||||
PRIORITY = 0
|
PRIORITY = 0
|
||||||
|
|
||||||
# The `Regexp` used to determine if the strategy applies to the URL.
|
# The `Regexp` used to determine if the strategy applies to the URL.
|
||||||
@ -1,6 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "livecheck/strategy/github_release"
|
require "livecheck/strategy/github_releases"
|
||||||
require "livecheck/strategy/github_latest"
|
require "livecheck/strategy/github_latest"
|
||||||
|
|
||||||
describe Homebrew::Livecheck::Strategy::GithubLatest do
|
describe Homebrew::Livecheck::Strategy::GithubLatest do
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
require "livecheck/strategy"
|
require "livecheck/strategy"
|
||||||
|
|
||||||
describe Homebrew::Livecheck::Strategy::GitHubReleases do
|
describe Homebrew::Livecheck::Strategy::GithubReleases do
|
||||||
subject(:github_release) { described_class }
|
subject(:github_releases) { described_class }
|
||||||
|
|
||||||
let(:github_urls) do
|
let(:github_urls) do
|
||||||
{
|
{
|
||||||
@ -14,7 +14,7 @@ describe Homebrew::Livecheck::Strategy::GitHubReleases do
|
|||||||
end
|
end
|
||||||
let(:non_github_url) { "https://brew.sh/test" }
|
let(:non_github_url) { "https://brew.sh/test" }
|
||||||
|
|
||||||
let(:regex) { github_release::DEFAULT_REGEX }
|
let(:regex) { github_releases::DEFAULT_REGEX }
|
||||||
|
|
||||||
let(:generated) do
|
let(:generated) do
|
||||||
{
|
{
|
||||||
@ -85,55 +85,55 @@ describe Homebrew::Livecheck::Strategy::GitHubReleases do
|
|||||||
|
|
||||||
describe "::match?" do
|
describe "::match?" do
|
||||||
it "returns true for a GitHub release artifact URL" do
|
it "returns true for a GitHub release artifact URL" do
|
||||||
expect(github_release.match?(github_urls[:release_artifact])).to be true
|
expect(github_releases.match?(github_urls[:release_artifact])).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true for a GitHub tag archive URL" do
|
it "returns true for a GitHub tag archive URL" do
|
||||||
expect(github_release.match?(github_urls[:tag_archive])).to be true
|
expect(github_releases.match?(github_urls[:tag_archive])).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true for a GitHub repository upload URL" do
|
it "returns true for a GitHub repository upload URL" do
|
||||||
expect(github_release.match?(github_urls[:repository_upload])).to be true
|
expect(github_releases.match?(github_urls[:repository_upload])).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false for a non-GitHub URL" do
|
it "returns false for a non-GitHub URL" do
|
||||||
expect(github_release.match?(non_github_url)).to be false
|
expect(github_releases.match?(non_github_url)).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "::generate_input_values" do
|
describe "::generate_input_values" do
|
||||||
it "returns a hash containing a url and regex for a GitHub release artifact URL" do
|
it "returns a hash containing a url and regex for a GitHub release artifact URL" do
|
||||||
expect(github_release.generate_input_values(github_urls[:release_artifact])).to eq(generated)
|
expect(github_releases.generate_input_values(github_urls[:release_artifact])).to eq(generated)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a hash containing a url and regex for a GitHub tag archive URL" do
|
it "returns a hash containing a url and regex for a GitHub tag archive URL" do
|
||||||
expect(github_release.generate_input_values(github_urls[:tag_archive])).to eq(generated)
|
expect(github_releases.generate_input_values(github_urls[:tag_archive])).to eq(generated)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a hash containing a url and regex for a GitHub repository upload URL" do
|
it "returns a hash containing a url and regex for a GitHub repository upload URL" do
|
||||||
expect(github_release.generate_input_values(github_urls[:repository_upload])).to eq(generated)
|
expect(github_releases.generate_input_values(github_urls[:repository_upload])).to eq(generated)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an empty hash for a non-Github URL" do
|
it "returns an empty hash for a non-Github URL" do
|
||||||
expect(github_release.generate_input_values(non_github_url)).to eq({})
|
expect(github_releases.generate_input_values(non_github_url)).to eq({})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "::versions_from_content" do
|
describe "::versions_from_content" do
|
||||||
it "returns an empty array if content is blank" do
|
it "returns an empty array if content is blank" do
|
||||||
expect(github_release.versions_from_content({}, regex)).to eq([])
|
expect(github_releases.versions_from_content({}, regex)).to eq([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an array of version strings when given content" do
|
it "returns an array of version strings when given content" do
|
||||||
expect(github_release.versions_from_content(json, regex)).to eq(matches)
|
expect(github_releases.versions_from_content(json, regex)).to eq(matches)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an array of version strings when given content and a block" do
|
it "returns an array of version strings when given content and a block" do
|
||||||
# Returning a string from block
|
# Returning a string from block
|
||||||
expect(github_release.versions_from_content(json, regex) { "1.2.3" }).to eq(["1.2.3"])
|
expect(github_releases.versions_from_content(json, regex) { "1.2.3" }).to eq(["1.2.3"])
|
||||||
|
|
||||||
# Returning an array of strings from block
|
# Returning an array of strings from block
|
||||||
expect(github_release.versions_from_content(json, regex) do |json, regex|
|
expect(github_releases.versions_from_content(json, regex) do |json, regex|
|
||||||
json.map do |release|
|
json.map do |release|
|
||||||
next if release["draft"] || release["prerelease"]
|
next if release["draft"] || release["prerelease"]
|
||||||
|
|
||||||
@ -146,11 +146,11 @@ describe Homebrew::Livecheck::Strategy::GitHubReleases do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "allows a nil return from a block" do
|
it "allows a nil return from a block" do
|
||||||
expect(github_release.versions_from_content(json, regex) { next }).to eq([])
|
expect(github_releases.versions_from_content(json, regex) { next }).to eq([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "errors on an invalid return type from a block" do
|
it "errors on an invalid return type from a block" do
|
||||||
expect { github_release.versions_from_content(json, regex) { 123 } }
|
expect { github_releases.versions_from_content(json, regex) { 123 } }
|
||||||
.to raise_error(TypeError, Homebrew::Livecheck::Strategy::INVALID_BLOCK_RETURN_VALUE_MSG)
|
.to raise_error(TypeError, Homebrew::Livecheck::Strategy::INVALID_BLOCK_RETURN_VALUE_MSG)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user