Flagging neglected git commits

I store all my coding projects in a Programming directory that I have Hazel run rules to achieve two things: sync changed files and to flag up neglected git repositories. I have an unfortunate habit of working and forgetting to commit anything. To deal with this, I've tried to use Hazel to flag up projects with forgotten about commits.
To start with I tag folders I'm interested in, then there is a three step process:
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.
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.
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.