<pre style='margin:0'>
Aaron Madlon-Kay (amake) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/de548131685c38b3ea1b132ed9957dd91ae5e402">https://github.com/macports/macports-ports/commit/de548131685c38b3ea1b132ed9957dd91ae5e402</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit de548131685c38b3ea1b132ed9957dd91ae5e402
</span>Author: Aaron Madlon-Kay <aaron@madlon-kay.com>
AuthorDate: Tue Sep 13 11:53:49 2022 +0900
<span style='display:block; white-space:pre;color:#404040;'> bitbucket portgroup: fix livecheck for tags, branches
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Previous URLs were giving empty responses or otherwise not behaving as expected.
</span><span style='display:block; white-space:pre;color:#404040;'> Use the official API instead of scraping the website.
</span>---
_resources/port1.0/group/bitbucket-1.0.tcl | 35 ++++++++++++++----------------
1 file changed, 16 insertions(+), 19 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/_resources/port1.0/group/bitbucket-1.0.tcl b/_resources/port1.0/group/bitbucket-1.0.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index ddcfbe201d5..cb57d47fd87 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/_resources/port1.0/group/bitbucket-1.0.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/_resources/port1.0/group/bitbucket-1.0.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -9,10 +9,13 @@
</span>
options bitbucket.author bitbucket.project bitbucket.version bitbucket.tag_prefix
options bitbucket.homepage bitbucket.master_sites bitbucket.tarball_from
<span style='display:block; white-space:pre;background:#ffe0e0;'>-options bitbucket.livecheck_branch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+options bitbucket.livecheck_branch bitbucket.api_endpoint
</span>
default bitbucket.homepage {https://bitbucket.org/${bitbucket.author}/${bitbucket.project}}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# Reference: https://developer.atlassian.com/cloud/bitbucket/rest/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+default bitbucket.api_endpoint {https://api.bitbucket.org/2.0}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # Later code assumes that bitbucket.master_sites is a simple string, not a list.
default bitbucket.master_sites {${bitbucket.homepage}/get}
default bitbucket.tarball_from tags
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -35,19 +38,20 @@ proc handle_tarball_from {option action args} {
</span>
proc bitbucket.livecheck_regex {} {
global bitbucket.tag_prefix bitbucket.tarball_from distname extract.suffix version
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dist_pattern [regsub -- [quotemeta ${version}] ${distname} {([0-9.]+)}]
</span> switch ${bitbucket.tarball_from} {
tags {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set dir get
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return "\\\"${dist_pattern}\\\""
</span> }
default {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set dir ${bitbucket.tarball_from}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ${dir}/${dist_pattern}[quotemeta [quotemeta ${extract.suffix}]]
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return ${dir}/[regsub -- [quotemeta ${version}] ${distname} {([0-9.]+)}][quotemeta [quotemeta ${extract.suffix}]]
</span> }
proc bitbucket.setup {bb_author bb_project bb_version {bb_tag_prefix ""}} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global bitbucket.author bitbucket.homepage bitbucket.master_sites bitbucket.project bitbucket.tag_prefix bitbucket.version extract.suffix PortInfo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global bitbucket.author bitbucket.homepage bitbucket.master_sites bitbucket.project bitbucket.tag_prefix bitbucket.version PortInfo bitbucket.api_endpoint
</span>
bitbucket.author ${bb_author}
bitbucket.project ${bb_project}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -76,16 +80,9 @@ proc bitbucket.setup {bb_author bb_project bb_version {bb_tag_prefix ""}} {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[join ${bitbucket.tag_prefix}] eq "" && \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- [regexp "^\[0-9a-f\]{9,}\$" ${bitbucket.version}]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- default livecheck.type regexm
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- default livecheck.url {${bitbucket.homepage}/atom}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- default livecheck.regex {<id>changeset:(\[0-9a-f\]{[string length ${bitbucket.version}]})\[0-9a-f\]*</id>}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- default livecheck.type regex
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- default livecheck.url {${bitbucket.homepage}/downloads?tab=tags}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- default livecheck.regex {[bitbucket.livecheck_regex]}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default livecheck.type regex
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default livecheck.url {${bitbucket.api_endpoint}/repositories/${bitbucket.author}/${bitbucket.project}/refs/tags?sort=-target.date}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default livecheck.regex {[bitbucket.livecheck_regex]}
</span>
default livecheck.version {${bitbucket.version}}
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -94,9 +91,9 @@ proc bitbucket.setup {bb_author bb_project bb_version {bb_tag_prefix ""}} {
</span> # commits (meant to be used when the version is a hash); to be called *after*
# bitbucket.setup
proc bitbucket.livecheck {bb_branch} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global bitbucket.homepage bitbucket.author bitbucket.project bitbucket.version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global bitbucket.author bitbucket.project bitbucket.version bitbucket.api_endpoint
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- livecheck.url ${bitbucket.homepage}/commits/branch/${bb_branch}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- livecheck.type regexm
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- livecheck.regex <a class="hash execute" href="/${bitbucket.author}/${bitbucket.project}/commits/(\[0-9a-f\]{[string length ${bitbucket.version}]}).*"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ livecheck.url ${bitbucket.api_endpoint}/repositories/${bitbucket.author}/${bitbucket.project}/commits/${bb_branch}?pagelen=1&sort=-date&fields=values.hash
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ livecheck.type regex
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ livecheck.regex {"([0-9a-f]+)"}
</span> }
</pre><pre style='margin:0'>
</pre>