Skip to content

Instantly share code, notes, and snippets.

@tarao
Last active July 13, 2020 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarao/506d8e66fbc7059db156a51eb4e5cbcb to your computer and use it in GitHub Desktop.
Save tarao/506d8e66fbc7059db156a51eb4e5cbcb to your computer and use it in GitHub Desktop.
#!/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"
@tarao
Copy link
Author

tarao commented Jul 13, 2020

> ./maven-diff-url.sh com.github.tarao:nonempty_2.12 0.0.7 0.0.8
https://github.com/tarao/nonempty-scala/compare/v0.0.7...v0.0.8
> ./maven-diff-url.sh com.typesafe.slick:slick_2.12 3.2.1 3.3.2
https://github.com/slick/slick/compare/v3.2.1...v3.3.2

@tarao
Copy link
Author

tarao commented Jul 13, 2020

(メモ) scala-stewardだとどうしてるか

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment