Skip to content

Instantly share code, notes, and snippets.

@niedbalski
Created June 10, 2019 18:48
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 niedbalski/1664d8f16e1bc0cd19b91a9d0d8d65df to your computer and use it in GitHub Desktop.
Save niedbalski/1664d8f16e1bc0cd19b91a9d0d8d65df to your computer and use it in GitHub Desktop.
charmhead.sh
function charmhead() {
if [ ! ${#@} -ge 2 ]; then
echo "usage ./$0 charm revision" && return;
fi
q=$(curl -s https://api.jujucharms.com/charmstore/v5/$1-$2/archive/repo-info | python -c "import sys, re; q=map(lambda x: re.search('.*commit-short\: (.*)', x), sys.stdin.readlines()); print(q[1].group(1))")
if [ -n "$q" ]; then
echo "$q";
else
echo "Not found revision for charm: $1"
fi
}
export -f charmhead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment