Last active
July 13, 2020 04:46
-
-
Save tarao/506d8e66fbc7059db156a51eb4e5cbcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
artifact="$1" | |
old="$2" | |
new="$3" | |
namespace="$(echo "$artifact" | cut -f 1 -d :)" | |
id="$(echo "$artifact" | cut -f 2 -d :)" | |
pom_url="https://repo1.maven.org/maven2/$(echo "$namespace" | tr . /)/$id/$new/$id-$new.pom" | |
pom_xml="$(curl -sL "$pom_url")" | |
scm_url="$(echo "$pom_xml" | xmllint --xpath "/*[local-name()='project']/*[local-name()='scm']/*[local-name()='url']/text()" -)" | |
url="$(echo "$pom_xml" | xmllint --xpath "/*[local-name()='project']/*[local-name()='url']/text()" -)" | |
scm_url="$(echo "$scm_url" | sed 's!^git@github.com:!https://github.com/!')" | |
scm_url="$(echo "$scm_url" | sed 's![.]git$!!')" | |
[ -n "$scm_url" ] && { | |
case "$scm_url" in | |
'https://github.com/'*) | |
[ "$(git ls-remote "$scm_url" "$new" | wc -l)" = 1 ] && { | |
echo "$scm_url/compare/${old}...${new}" | |
exit | |
} | |
[ "$(git ls-remote "$scm_url" "v$new" | wc -l)" = 1 ] && { | |
echo "$scm_url/compare/v${old}...v${new}" | |
exit | |
} | |
echo "$scm_url" | |
;; | |
*) | |
echo "$scm_url" | |
;; | |
esac | |
exit | |
} | |
[ -n "$url" ] && echo "$url" |
Author
tarao
commented
Jul 13, 2020
(メモ) scala-stewardだとどうしてるか
vなんとか
の他にrelease-なんとか
も見てる- 取り出す対象のURLも似た感じ
- pomの情報の取得はcoursierに任せてる?
- 正しいタグ形式かどうかは実際にリクエストした上で
200
が返るかどうかで判別してる- GitHubでタグをミスったcompareなURLはHTMLが返るけどステータスは
404
になっているようだ - 例: tarao/nonempty-scala@0.0.7...0.0.8
- GitHubでタグをミスったcompareなURLはHTMLが返るけどステータスは
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment