Skip to content

Instantly share code, notes, and snippets.

@niedbalski
Created June 13, 2017 20:04
Show Gist options
  • Select an option

  • Save niedbalski/56ea832139812d9309c01a09fddf36f2 to your computer and use it in GitHub Desktop.

Select an option

Save niedbalski/56ea832139812d9309c01a09fddf36f2 to your computer and use it in GitHub Desktop.
Check if the latest published artifact on charmstore matches with current github tip for a given branch
function charmislatest() {
if [ ! ${#@} -ge 2 ]; then
echo -e "Please provide a charm name and a branch" && return;
fi
q=$(curl -s https://api.github.com/repos/openstack/charm-$1/commits/stable/$2 | python -c "import sys, json; q=json.load(sys.stdin); print q['sha']")
head=$(curl -s https://api.jujucharms.com/charmstore/v5/$1/meta/extra-info | python -c "import sys, json; q=json.load(sys.stdin)['vcs-revisions'][-1]; print q['commit'];")
if [ "$head" == "$q" ]; then
echo "OK - $1 (Charmstore: $head == Github($2): $q)"
else
echo "Not OK - Charm is not latest: $q != $head"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment