Skip to content

lorenzwalthert/precommit

Folders and files

NameName
Last commit message
Last commit date
Mar 16, 2025
Mar 26, 2025
Apr 1, 2025
Mar 26, 2025
Apr 1, 2025
Jan 21, 2024
Mar 26, 2025
Mar 26, 2025
Jan 21, 2024
Nov 12, 2022
Apr 7, 2025
Dec 13, 2024
Mar 26, 2025
Dec 15, 2024
Apr 1, 2025
Oct 12, 2019
Oct 3, 2023
Jul 22, 2024
Aug 1, 2022
Jan 21, 2024
Jun 14, 2022
Jul 20, 2024
Jan 31, 2025
Apr 1, 2025

Repository files navigation

editor_options
markdown
wrap
72

Useful git pre-commit hooks for R

CRAN status Lifecycle: stable R build status

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 the code is parsable, making sure you have not forgotten a comma, brace or quote. You can run hooks locally and/or in the cloud:

  • As a check before local commits: This requires installing pre-commit.

  • As a CI check with https://pre-commit.ci: If you want to enforce passing hooks on pull requests (and auto-fix trivial problems like styling) even if the committer does not have a local installation.

Goals of the package

The goal of this package is to twofold:

  • Provide a set of hooks that are useful when your git repo contains R code.

  • Provide usethis-like functionality for common tasks such as installation and set-up and config file modification.

Why do I need pre-commit hooks?

By Mara Averick

For a more in-depth explanation and even more reasons, see vignette("why-use-hooks").

Documentation

The following online docs are available:

These only cover the functionality added on top of the pre-commit framework by this package. Everything else is covered in the extensive online documentation of the pre-commit framework itself, including how to create hooks for actions like git push or git checkout, create local hooks etc.