Skip to content

Commit 5e1941f

Browse files
decouple .pre-commit-config.yaml template from the one used in this repo
1 parent 3e80206 commit 5e1941f

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/usr/bin/env Rscript
22
library(magrittr)
3-
exclude_hooks <- yaml::read_yaml(here::here(".pre-commit-hooks.yaml")) %>%
4-
purrr::keep(~ .x$id == "spell-check") %>%
5-
magrittr::extract2(1) %>%
6-
purrr::pluck("exclude")
7-
83
read_config <- function(path) {
94
yaml::read_yaml(path) %>%
105
purrr::pluck("repos") %>%
@@ -13,17 +8,10 @@ read_config <- function(path) {
138
purrr::keep(~ .x$id == "spell-check") %>%
149
purrr::pluck(1, "exclude")
1510
}
16-
17-
if (!identical(exclude_hooks, read_config(here::here("inst/pre-commit-config-pkg.yaml")))) {
11+
hooks_pkg <- read_config(here::here("inst/pre-commit-config-pkg.yaml"))
12+
hooks_proj <- read_config(here::here("inst/pre-commit-config-proj.yaml"))
13+
if (!identical(hooks_proj, hooks_pkg)) {
1814
rlang::abort(paste0(
19-
"The `exclude` key from the spell-check hook should be copied from `.pre-commit-hooks.yaml` to ",
20-
"`inst/pre-commit-config-pkg.yaml` so the two match."
21-
))
22-
}
23-
24-
if (!identical(exclude_hooks, read_config(here::here("inst/pre-commit-config-proj.yaml")))) {
25-
rlang::abort(paste0(
26-
"The `exclude` key from the spell-check hook should be copied from `.pre-commit-hooks.yaml` to ",
27-
"`inst/pre-commit-config-proj.yaml` so the two match."
15+
"The `exclude` key from the spell-check hook should be the same for all templates in `inst/`."
2816
))
2917
}

inst/pre-commit-config-pkg.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ repos:
5959
entry: Cannot commit .Rhistory, .RData, .Rds or .rds.
6060
language: fail
6161
files: '\.Rhistory|\.RData|\.Rds|\.rds$'
62-
# `exclude: <regex>` to allow committing specific files.
62+
# `exclude: <regex>` to allow committing specific files

inst/pre-commit-config-proj.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ repos:
5454
entry: Cannot commit .Rhistory, .RData, .Rds or .rds.
5555
language: fail
5656
files: '\.Rhistory|\.RData|\.Rds|\.rds$'
57-
# `exclude: <regex>` to allow committing specific files.
57+
# `exclude: <regex>` to allow committing specific files

0 commit comments

Comments
 (0)