use_precommit | R Documentation |
This function sets up pre-commit for your git repo.
use_precommit(
config_source = getOption("precommit.config_source"),
force = FALSE,
legacy_hooks = "forbid",
open = rstudioapi::isAvailable(),
install_hooks = TRUE,
ci = getOption("precommit.ci", "native"),
autoupdate = install_hooks,
root = here::here()
)
config_source |
Path or URL to a |
force |
Whether or not to overwrite an existing ci config file (only
relevant for |
legacy_hooks |
How to treat hooks already in the repo which are not
managed by pre-commit. "forbid", the default, will cause |
open |
Whether or not to open |
install_hooks |
Whether to install environments for all available hooks.
If |
ci |
Specifies which continuous integration service to use. See
|
autoupdate |
Whether or not to run |
root |
The path to the root directory of your project. |
NULL
(invisibly). The function is called for its side effects.
You want to add pre-commit support to a git repo which does not have a
.pre-commit-config.yaml
. This involves adding
a pre-commit config file and making sure git will call the hooks before
the next commit.
You cloned a repo that has a .pre-commit-config.yaml
already. You need
to make sure git calls the hooks before the next commit.
Sets up a template .pre-commit-config.yaml
.
Autoupdates the template to make sure you get the latest versions of the hooks.
Installs the pre-commit script along with the hook environments with
$ pre-commit install --install-hooks
.
Opens the config file if RStudio is running.
You can use an existing .pre-commit-config.yaml
file when initializing
pre-commit with use_precommit()
using the argument config_source
to
copy an existing config file into your repo. This argument defaults to the R
option precommit.config_source
, so you may want to set this option in
your .Rprofile
for convenience. Note that this is not equivalent to the
--config
option in the CLI command pre-commit install
and similar,
which do not copy a config file into a project root (and allow to put it
under version control), but rather link it in some more or less transparent
way.
Other helpers:
open_config()
## Not run:
use_precommit()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.