Last active
May 4, 2020 18:46
-
-
Save teone/c2cf388ecf963a803207f7b9fa7fdda3 to your computer and use it in GitHub Desktop.
check the commits between two images in the opencord repo
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
images=( "$@" ) | |
commits=() | |
if [ ${#images[@]} != 2 ] | |
then | |
printf "You need to provide two images only, eg:\n" | |
printf "\tbash $0 voltha/voltha-rw-core:2.3.6 voltha/voltha-rw-core:2.4.0\n" | |
exit 1 | |
fi | |
printf "\nDownloading images\n" | |
for image in ${images[*]} | |
do | |
docker pull $image | |
done | |
printf "\nChecking commit used to build image\n" | |
for image in ${images[*]} | |
do | |
commit=$(docker inspect $image | jq -r '.[].Config.Labels["org.label-schema.vcs-ref"]') | |
commits+=("$commit") | |
done | |
echo "${commits[0]}" "${commits[1]}" | |
printf "\nChecking for repo\n" | |
for image in ${images[*]} | |
do | |
repo=$(docker inspect $image | jq -r '.[].Config.Labels["org.label-schema.vcs-url"]') | |
done | |
echo $repo | |
printf "\nCloning repo\n" | |
mkdir -p tmp | |
cd tmp && git clone $repo . | |
image_name=$(echo $images[0]| grep -oE "\/([a-z-]+)[:@]" | awk '{print substr($0, 2, length($0) - 2)}') | |
printf "\nCommits between the two $image_name images\n" | |
git log --pretty="%C(Yellow)%h %C(reset)%ad (%C(Green)%cr%C(reset))%x09 %C(Cyan)%an: %C(reset)%s" "${commits[0]}".."${commits[1]}" | |
cd .. | |
rm -rf tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment