Skip to content

Instantly share code, notes, and snippets.

@gadenbuie
Forked from jeroenjanssens/pre-commit
Created December 18, 2018 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gadenbuie/b952d20ffcbe00a6893bd9e04b923059 to your computer and use it in GitHub Desktop.
Save gadenbuie/b952d20ffcbe00a6893bd9e04b923059 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