50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

precommit (version 0.0.0.9029)

use_precommit_config: Initiate a pre-commit config file

Description

Initiate a pre-commit config file

Usage

use_precommit_config(
  path_cp_config_from = getOption("precommit.path_cp_config_from"),
  force,
  open = rstudioapi::isAvailable(),
  path_root = here::here(),
  verbose = FALSE
)

Arguments

path_cp_config_from

Path or URL to a .pre-commit-config.yaml. This config file will be hard-copied into path_root. If NULL, we use a default config from the path returned by system.file("pre-commit-config.yaml", package = "precommit"). See section 'Copying an existing config file'.

force

Whether to replace an existing config file.

open

Whether or not to open the .pre-commit-config.yaml after it's been placed in your repo. The default is TRUE when working in RStudio. Otherwise, we recommend manually inspecting the file.

path_root

The path to the root directory of your project.

verbose

Whether or not to communicate what's happening.

Copying an existing config file

You can use an existing .pre-commit-config.yaml file when intiializing pre-commit with use_precommit() using the argument path_cp_config_from to copy an existing config file into your repo. This argument defaults to the R option precommit.path_cp_config_from, 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.