Site icon R-bloggers

precommit initial CRAN release

[This article was first published on Posts on Lorenz Walthert, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I am happy to announce that {precommit} 0.1.2 is available from CRAN. Pre-commit hooks are tests that run each time you attempt to commit. If the tests pass, the commit will be made, otherwise not. A very basic test is to check if code is syntactically valid, making sure you have not forgotten a comma, brace or quote. Such hooks increase the quality of commits and the consistency in a code base. The goal of this package is to twofold:

Note that because pre-commit is a language agnostic framework to manage git hooks, you can add other useful hooks to your git repo that are written in / for other languages, e.g. hooks from https://github.com/pre-commit/pre-commit-hooks. Some useful other hooks I discovered in this repo are:

There is also a list with many more repos that contain useful hooks.

Convinced? Let’s get started. You’ll find all relevant installation and usage instructions in the README.

If you already use {precommit}…

To guarantee a smooth experience, I suggest everyone who currently uses a devel version to upgrade both the R package (with install.package("precommit")) and the hook reversion (with precommit::autoupdate()). Depending on which devel version you use, we might also have added new hooks and changed the order in the default config file for a better user experience, so you could also make a copy of your current .pre-commit-config.yaml file and then use precommit::use_precommit(force = TRUE) in your repo to replace the config file and then manually port your deviations from the template config to the new config.

If you use conda, you may need to precommit::install_precommit(force = TRUE). You can also check the changelog for breaking changes we introduced before the CRAN release so you can adapt. In particular:

If you are a GitHub Action specialist..

We currently use travis in a non-standard setup because we also have to test different installation methods (pip, conda, brew) on different platforms (macOS, Linux, Windows), but I’d like to switch to GitHub Actions. If you have experience and want to contribute to this, please open an issue on GitHub.

To leave a comment for the author, please follow the link and comment on their blog: Posts on Lorenz Walthert.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.