-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(R): check README.Rmd changes are rendered
Adds the githook generated by usethis::use_readme_rmd() to pre-commits, ensuring any changes made to README.Rmd are properly synchronised to the rendered README.md file.
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
README=($(git diff --cached --name-only | grep -Ei '^README\.[R]?md$')) | ||
|
||
if [[ ${#README[@]} == 0 ]]; then | ||
exit 0 | ||
fi | ||
|
||
if [[ README.Rmd -nt README.md ]]; then | ||
echo -e "README.md is out of date; please re-knit README.Rmd" | ||
exit 1 | ||
elif [[ ${#README[@]} -lt 2 ]]; then | ||
echo -e "README.Rmd and README.md should be both staged" | ||
exit 1 | ||
fi |