Checks if staging area for git directories given through stdin is empty
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 | |
# This script checks if the staging area for git directories in $1 is empty | |
while read line; do | |
dir=$line | |
curdir=$PWD | |
cd $dir | |
gitroot=`git rev-parse --show-toplevel` | |
cd $gitroot | |
if [[ -z "$gitroot" ]] | |
then | |
echo "No git directory @ $dir!" | |
cd $curdir | |
exit 1 | |
fi | |
changed=`git status -s | grep -v "^??"` | |
if [[ -z "$changed" ]] | |
then | |
cd $curdir | |
else | |
cd $curdir | |
printf "There are changed files in $dir:\n$changed" | |
exit 1 | |
fi | |
done < "${1:-/dev/stdin}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment