Created
January 19, 2019 13:55
-
-
Save machta/e5ba03be62f34e8bbecaf22aaefee8fc to your computer and use it in GitHub Desktop.
Checks that this repository and all of its submodules point to the tip of a certain BRANCH
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/bash | |
# | |
# Usage ./git-check-versions.sh BRANCH | |
# | |
# Checks that this repository and all of its submodules point to the tip of | |
# a certain BRANCH. | |
BRANCH=$1 | |
check() { | |
cd $2 | |
BRANCH_HASH=`git log --pretty=format:"%H" $BRANCH -- 2>/dev/null | head -1` | |
[ "$BRANCH_HASH" = "$1" ] || | |
echo "$2 doesn't point to the tip of branch $BRANCH" | |
cd - >/dev/null | |
} | |
# Check this repo | |
check `git log --pretty=format:"%H" | head -1` . | |
# Also check submodules | |
git submodule status --recursive | while read line ; do | |
SUB_HASH=`echo $line | awk '{print $1}'` | |
SUB_PATH=`echo $line | awk '{print $2}'` | |
check $SUB_HASH $SUB_PATH | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment