Merge pull request #15463 from samford/livecheck/fix-bitbucket-tag-match
Bitbucket: Fix tag match
This commit is contained in:
commit
cd99f72bc3
@ -61,24 +61,29 @@ module Homebrew
|
|||||||
match = url.match(URL_MATCH_REGEX)
|
match = url.match(URL_MATCH_REGEX)
|
||||||
return values if match.blank?
|
return values if match.blank?
|
||||||
|
|
||||||
# `/get/` archives are Git tag snapshots, so we need to check that tab
|
|
||||||
# instead of the main `/downloads/` page
|
|
||||||
values[:url] = if match[:dl_type] == "get"
|
|
||||||
"https://bitbucket.org/#{match[:path]}/downloads/?tab=tags"
|
|
||||||
else
|
|
||||||
"https://bitbucket.org/#{match[:path]}/downloads/"
|
|
||||||
end
|
|
||||||
|
|
||||||
regex_prefix = Regexp.escape(T.must(match[:prefix])).gsub("\\-", "-")
|
regex_prefix = Regexp.escape(T.must(match[:prefix])).gsub("\\-", "-")
|
||||||
|
|
||||||
# Use `\.t` instead of specific tarball extensions (e.g. .tar.gz)
|
# `/get/` archives are Git tag snapshots, so we need to check that tab
|
||||||
suffix = T.must(match[:suffix]).sub(Strategy::TARBALL_EXTENSION_REGEX, ".t")
|
# instead of the main `/downloads/` page
|
||||||
regex_suffix = Regexp.escape(suffix).gsub("\\-", "-")
|
if match[:dl_type] == "get"
|
||||||
|
values[:url] = "https://bitbucket.org/#{match[:path]}/downloads/?tab=tags"
|
||||||
|
|
||||||
# Example regexes:
|
# Example tag regexes:
|
||||||
# * `/href=.*?v?(\d+(?:\.\d+)+)\.t/i`
|
# * `/<td[^>]*?class="name"[^>]*?>\s*v?(\d+(?:\.\d+)+)\s*?</im`
|
||||||
# * `/href=.*?example-v?(\d+(?:\.\d+)+)\.t/i`
|
# * `/<td[^>]*?class="name"[^>]*?>\s*abc-v?(\d+(?:\.\d+)+)\s*?</im`
|
||||||
values[:regex] = /href=.*?#{regex_prefix}v?(\d+(?:\.\d+)+)#{regex_suffix}/i
|
values[:regex] = /<td[^>]*?class="name"[^>]*?>\s*#{regex_prefix}v?(\d+(?:\.\d+)+)\s*?</im
|
||||||
|
else
|
||||||
|
values[:url] = "https://bitbucket.org/#{match[:path]}/downloads/"
|
||||||
|
|
||||||
|
# Use `\.t` instead of specific tarball extensions (e.g. .tar.gz)
|
||||||
|
suffix = T.must(match[:suffix]).sub(Strategy::TARBALL_EXTENSION_REGEX, ".t")
|
||||||
|
regex_suffix = Regexp.escape(suffix).gsub("\\-", "-")
|
||||||
|
|
||||||
|
# Example file regexes:
|
||||||
|
# * `/href=.*?v?(\d+(?:\.\d+)+)\.t/i`
|
||||||
|
# * `/href=.*?abc-v?(\d+(?:\.\d+)+)\.t/i`
|
||||||
|
values[:regex] = /href=.*?#{regex_prefix}v?(\d+(?:\.\d+)+)#{regex_suffix}/i
|
||||||
|
end
|
||||||
|
|
||||||
values
|
values
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ describe Homebrew::Livecheck::Strategy::Bitbucket do
|
|||||||
{
|
{
|
||||||
get: {
|
get: {
|
||||||
url: "https://bitbucket.org/abc/def/downloads/?tab=tags",
|
url: "https://bitbucket.org/abc/def/downloads/?tab=tags",
|
||||||
regex: /href=.*?v?(\d+(?:\.\d+)+)\.t/i,
|
regex: /<td[^>]*?class="name"[^>]*?>\s*v?(\d+(?:\.\d+)+)\s*?</im,
|
||||||
},
|
},
|
||||||
downloads: {
|
downloads: {
|
||||||
url: "https://bitbucket.org/abc/def/downloads/",
|
url: "https://bitbucket.org/abc/def/downloads/",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user