To start with I tag folders I'm interested in, then there is a three step process:
- Check tagged folders contain a repository, if not remove the tag
- Check tagged folders contain changes to the working directory, if so add tag and show notification
- Check tagged folders marked as containing uncommitted changes are clean, if so remove tag added in step 2
Most of the rules are just checking last matched and adding/removing tags appropriately. The core part of this process is the below script, which gets used in some modified way at each step.
- Code: Select all
cd "$1"
# find location of git repository
gitloc=`find . -name .git -type d -prune`
# test for a result
if [ -z $gitloc ]; then
exit 1
fi
parentdir="$(dirname "$gitloc")"
cd $parentdir
# check if clean
if git status | grep --quiet "working directory clean"; then
exit 1
else
exit 0
fi
The entire thing would no doubt benefit from removing the find calls or caching the result after it's been run once, but otherwise seems work as desired.