Skip to content

Instantly share code, notes, and snippets.

@anthager
Created February 25, 2019 22:47
Show Gist options
  • Select an option

  • Save anthager/eb6f7f044ea06b5b35965fe1800a378b to your computer and use it in GitHub Desktop.

Select an option

Save anthager/eb6f7f044ea06b5b35965fe1800a378b to your computer and use it in GitHub Desktop.
bash script for checking if a folder has been changed since last commit
#!/usr/bin/env bash
cd -- "$(dirname "BASH_SOURCE")"
set -e
# latest commit
LATEST_COMMIT=$(git rev-parse HEAD)
pwd
# latest commit where path/to/folder1 was changed
FOLDER_COMMIT=$(git log -1 --format=format:%H --full-diff $1)
if [ $FOLDER_COMMIT = $LATEST_COMMIT ];
then
echo "files in $1 has changed"
exit 0
else
echo "files in $1 is unchanged"
exit 1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment