@@ -6,37 +6,37 @@ if (!on_cran()) {
66 })
77
88 test_that(" can use pre-commit" , {
9- tempdir <- local_test_setup(quiet = FALSE )
9+ tempdir <- local_test_setup(quiet = FALSE , install_hooks = FALSE )
1010 expect_message(
11- use_precommit(open = FALSE , force = TRUE , root = tempdir ),
11+ use_precommit(open = FALSE , force = TRUE , install_hooks = FALSE , root = tempdir ),
1212 " to get the latest"
1313 )
1414 expect_message(
15- use_precommit(open = FALSE , force = FALSE , root = tempdir ),
15+ use_precommit(open = FALSE , force = FALSE , install_hooks = FALSE , root = tempdir ),
1616 " There is already "
1717 )
1818 })
1919
2020 test_that(" fails early if repo is not a git repo " , {
21- tempdir <- local_test_setup(git = FALSE , quiet = FALSE )
21+ tempdir <- local_test_setup(git = FALSE , quiet = FALSE , install_hooks = FALSE )
2222
2323 expect_error(
24- use_precommit(open = FALSE , root = tempdir ),
24+ use_precommit(open = FALSE , install_hooks = FALSE , root = tempdir ),
2525 " is not a git repo"
2626 )
2727 })
2828
2929 test_that(" can use custom config file " , {
30- tempdir1 <- local_test_setup()
31- tempdir2 <- local_test_setup()
30+ tempdir1 <- local_test_setup(install_hooks = FALSE )
31+ tempdir2 <- local_test_setup(install_hooks = FALSE )
3232
3333 path_custom <- fs :: path(tempdir2 , " some-precommit.yaml" )
3434 new_text <- " # 4js93"
3535 readLines(system.file(" pre-commit-config-proj.yaml" , package = " precommit" )) %> %
3636 c(new_text ) %> %
3737 writeLines(path_custom )
3838 git2r :: init(tempdir1 )
39- use_precommit(config_source = path_custom , open = FALSE , force = TRUE , root = tempdir1 )
39+ use_precommit(config_source = path_custom , open = FALSE , force = TRUE , install_hooks = FALSE , root = tempdir1 )
4040 config <- readLines(fs :: path(tempdir1 , " .pre-commit-config.yaml" ))
4141 expect_equal(
4242 config [length(config )],
@@ -45,33 +45,33 @@ if (!on_cran()) {
4545 })
4646
4747 test_that(" existing hooks are recognized" , {
48- tempdir <- local_test_setup(quiet = FALSE )
48+ tempdir <- local_test_setup(quiet = FALSE , install_hooks = FALSE )
4949 withr :: with_dir(tempdir , {
5050 git2r :: init()
5151 usethis :: proj_set(" ." )
5252 usethis :: use_readme_rmd(open = FALSE )
5353
5454 # usethis hook is removed without error
5555 expect_message(
56- use_precommit(legacy_hooks = " forbid" , open = FALSE , root = " ." ),
56+ use_precommit(legacy_hooks = " forbid" , open = FALSE , install_hooks = FALSE , root = " ." ),
5757 " Removed the render-README hook,"
5858 )
5959 writeLines(letters , " .git/hooks/pre-commit" )
6060 expect_error(
61- use_precommit(legacy_hooks = " forbid" , open = FALSE , root = " ." ),
61+ use_precommit(legacy_hooks = " forbid" , open = FALSE , install_hooks = FALSE , root = " ." ),
6262 " existing hooks installed"
6363 )
6464
6565 # tolerate other hook scripts in migration mode
6666 expect_message(
67- use_precommit(legacy_hooks = " allow" , force = TRUE , open = FALSE , root = " ." ),
67+ use_precommit(legacy_hooks = " allow" , force = TRUE , open = FALSE , install_hooks = FALSE , root = " ." ),
6868 " Running in migration"
6969 )
7070
7171 # can also remove other hooks
7272 writeLines(letters , " .git/hooks/pre-commit" )
7373 expect_message(
74- use_precommit(legacy_hooks = " remove" , force = TRUE , open = FALSE , root = " ." ),
74+ use_precommit(legacy_hooks = " remove" , force = TRUE , open = FALSE , install_hooks = FALSE , root = " ." ),
7575 " Sucessfully installed"
7676 )
7777 })
@@ -80,7 +80,7 @@ if (!on_cran()) {
8080
8181 test_that(" Can uninstall pre-commit (repo scope)" , {
8282 # with all files there
83- tempdir <- local_test_setup(use_precommit = TRUE , quiet = FALSE )
83+ tempdir <- local_test_setup(use_precommit = TRUE , quiet = FALSE , install_hooks = FALSE )
8484 expect_message(
8585 uninstall_precommit(scope = " repo" , root = tempdir ),
8686 " Uninstalled pre-commit from repo scope.*"
@@ -94,7 +94,7 @@ if (!on_cran()) {
9494 )
9595
9696 # when there is no pre-commit.yaml anymore
97- suppressMessages(use_precommit(open = FALSE , force = TRUE , root = tempdir ))
97+ suppressMessages(use_precommit(open = FALSE , force = TRUE , install_hooks = FALSE , root = tempdir ))
9898 fs :: file_delete(fs :: path(tempdir , " .pre-commit-config.yaml" ))
9999 expect_message(
100100 uninstall_precommit(scope = " repo" , root = tempdir ),
@@ -104,13 +104,13 @@ if (!on_cran()) {
104104
105105 test_that(" Can uninstall (userly)" , {
106106 if (not_conda()) {
107- tempdir <- local_test_setup(use_precommit = TRUE , quiet = FALSE )
107+ tempdir <- local_test_setup(use_precommit = TRUE , quiet = FALSE , install_hooks = FALSE )
108108 expect_error(
109109 uninstall_precommit(scope = " user" , ask = " none" , root = tempdir ),
110110 " installed with conda"
111111 )
112112 } else {
113- tempdir <- local_test_setup(use_precommit = FALSE , quiet = FALSE )
113+ tempdir <- local_test_setup(use_precommit = FALSE , quiet = FALSE , install_hooks = FALSE )
114114 expect_message(
115115 uninstall_precommit(scope = " user" , ask = " none" , root = tempdir ),
116116 " Removed pre-commit from"
@@ -124,18 +124,18 @@ if (!on_cran()) {
124124
125125 test_that(" use_precommit fails when no user installation is found" , {
126126 skip_if(not_conda())
127- expect_error(use_precommit(open = FALSE , root = tempdir ), " installed on your system" )
127+ expect_error(use_precommit(open = FALSE , install_hooks = FALSE , root = tempdir ), " installed on your system" )
128128 })
129129
130130 test_that(" can install pre-commit with remote config" , {
131131 if (! not_conda()) {
132132 expect_error(install_precommit(), NA )
133133 }
134- tempdir <- local_test_setup(quiet = FALSE )
134+ tempdir <- local_test_setup(quiet = FALSE , install_hooks = FALSE )
135135 expect_message(
136136 use_precommit(
137137 example_remote_config(),
138- open = FALSE , force = TRUE , root = tempdir
138+ open = FALSE , force = TRUE , install_hooks = FALSE , root = tempdir
139139 ),
140140 " to get the latest"
141141 )
@@ -145,14 +145,14 @@ if (!on_cran()) {
145145 if (! not_conda()) {
146146 expect_message(install_precommit(), " already installed" )
147147 }
148- tempdir <- local_test_setup(use_precommit = FALSE , quiet = FALSE )
148+ tempdir <- local_test_setup(use_precommit = FALSE , quiet = FALSE , install_hooks = FALSE )
149149 withr :: with_dir(
150150 tempdir ,
151151 {
152152 withr :: defer(call_and_capture(" git" , " config --unset-all core.hooksPath" ))
153153 call_and_capture(" git" , " config core.hooksPath .githooks" )
154154 expect_error(
155- use_precommit(open = FALSE , force = TRUE , root = tempdir ),
155+ use_precommit(open = FALSE , force = TRUE , install_hooks = FALSE , root = tempdir ),
156156 " stdout: [ERROR] Cowardly refusing to install hooks with `core.hooksPath` set." ,
157157 fixed = TRUE
158158 )
0 commit comments