Running R pre-commit hooks
Overview
Pre-commit hooks are scripts that run automatically before a commit is finalized in Git. They’re used to catch issues early by enforcing checks like code formatting, linting, or running tests before changes are committed.
captain
(hook) is a package that allows you to run git pre-commit hooks in a R environment.
Installation
The captain
package can be installed from CRAN as follows:
install.packages("captain")
The latest version can be installed from GitHub as follows:
# install.packages("pak")
pak::pak("alexym1/captain")
Usage
Initialize pre-commit framework
captain::install_precommit()
Run hooks
captain::run_precommit()
Add hooks
Editing the .pre-commit-config
file using captain::edit_precommit_config()
:
Code of conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Acknowledgments
This logo was created by @obstacle.graphic.