Created
February 25, 2019 22:47
-
-
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
This file contains hidden or 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
| #!/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