Created
August 13, 2020 15:16
-
-
Save cimentadaj/f30bc7aac30dd278c04e4c487ae6e83a to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
MSG="use 'git commit --no-verify' to override this check" | |
files=$(ls -d vignettes/* | grep -Ei '\.orig$') | |
for fl in $files; do | |
# Remove .orig from the vignette files | |
rmd=$(echo $fl | sed 's/.orig//') | |
# Remove .Rmd to get the raw file name | |
vignettefile=$(echo $rmd | sed 's/.Rmd//') | |
# Check if the raw file name has changed in git (regardless of whether | |
# it's the .orig of .Rmd) | |
vignettes=($(git diff --name-only | grep -Ei $vignettefile)) | |
if | |
[[ "$fl" -nt "$rmd" ]]; then | |
echo -e "$rmd is out of date; Please re-knit $fl\n$MSG" | |
exit 1 | |
elif | |
[[ ${#vignettes[*]} -lt 2 && ${#vignettes[*]} -gt 0 ]]; then | |
echo -e "$fl and $rmd should be both staged\n$MSG" | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment