Skip to content

Instantly share code, notes, and snippets.

@jeroenjanssens
Created December 18, 2018 12:40
Show Gist options
  • Save jeroenjanssens/acde46b6e3ac1ad39ac31d048fbd4034 to your computer and use it in GitHub Desktop.
Save jeroenjanssens/acde46b6e3ac1ad39ac31d048fbd4034 to your computer and use it in GitHub Desktop.
Script that tests your #rstats code before committing to git. When you have failed tests the commit will be aborted. Requires the devtools, testthat, and purrr packages. Name this script `pre-commit`, make it executable, and place it in the .git/hooks subdirectory of your git repository.
#!/usr/bin/env RScript
messages <- purrr::map_chr(devtools::test(),
list("results", 1, "message"))
q("no", status = sum(messages != "success"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment