@@ -6,37 +6,37 @@ if (!on_cran()) {
6
6
})
7
7
8
8
test_that(" can use pre-commit" , {
9
- tempdir <- local_test_setup(quiet = FALSE )
9
+ tempdir <- local_test_setup(quiet = FALSE , install_hooks = FALSE )
10
10
expect_message(
11
- use_precommit(open = FALSE , force = TRUE , root = tempdir ),
11
+ use_precommit(open = FALSE , force = TRUE , install_hooks = FALSE , root = tempdir ),
12
12
" to get the latest"
13
13
)
14
14
expect_message(
15
- use_precommit(open = FALSE , force = FALSE , root = tempdir ),
15
+ use_precommit(open = FALSE , force = FALSE , install_hooks = FALSE , root = tempdir ),
16
16
" There is already "
17
17
)
18
18
})
19
19
20
20
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 )
22
22
23
23
expect_error(
24
- use_precommit(open = FALSE , root = tempdir ),
24
+ use_precommit(open = FALSE , install_hooks = FALSE , root = tempdir ),
25
25
" is not a git repo"
26
26
)
27
27
})
28
28
29
29
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 )
32
32
33
33
path_custom <- fs :: path(tempdir2 , " some-precommit.yaml" )
34
34
new_text <- " # 4js93"
35
35
readLines(system.file(" pre-commit-config-proj.yaml" , package = " precommit" )) %> %
36
36
c(new_text ) %> %
37
37
writeLines(path_custom )
38
38
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 )
40
40
config <- readLines(fs :: path(tempdir1 , " .pre-commit-config.yaml" ))
41
41
expect_equal(
42
42
config [length(config )],
@@ -45,33 +45,33 @@ if (!on_cran()) {
45
45
})
46
46
47
47
test_that(" existing hooks are recognized" , {
48
- tempdir <- local_test_setup(quiet = FALSE )
48
+ tempdir <- local_test_setup(quiet = FALSE , install_hooks = FALSE )
49
49
withr :: with_dir(tempdir , {
50
50
git2r :: init()
51
51
usethis :: proj_set(" ." )
52
52
usethis :: use_readme_rmd(open = FALSE )
53
53
54
54
# usethis hook is removed without error
55
55
expect_message(
56
- use_precommit(legacy_hooks = " forbid" , open = FALSE , root = " ." ),
56
+ use_precommit(legacy_hooks = " forbid" , open = FALSE , install_hooks = FALSE , root = " ." ),
57
57
" Removed the render-README hook,"
58
58
)
59
59
writeLines(letters , " .git/hooks/pre-commit" )
60
60
expect_error(
61
- use_precommit(legacy_hooks = " forbid" , open = FALSE , root = " ." ),
61
+ use_precommit(legacy_hooks = " forbid" , open = FALSE , install_hooks = FALSE , root = " ." ),
62
62
" existing hooks installed"
63
63
)
64
64
65
65
# tolerate other hook scripts in migration mode
66
66
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 = " ." ),
68
68
" Running in migration"
69
69
)
70
70
71
71
# can also remove other hooks
72
72
writeLines(letters , " .git/hooks/pre-commit" )
73
73
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 = " ." ),
75
75
" Sucessfully installed"
76
76
)
77
77
})
@@ -80,7 +80,7 @@ if (!on_cran()) {
80
80
81
81
test_that(" Can uninstall pre-commit (repo scope)" , {
82
82
# 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 )
84
84
expect_message(
85
85
uninstall_precommit(scope = " repo" , root = tempdir ),
86
86
" Uninstalled pre-commit from repo scope.*"
@@ -94,7 +94,7 @@ if (!on_cran()) {
94
94
)
95
95
96
96
# 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 ))
98
98
fs :: file_delete(fs :: path(tempdir , " .pre-commit-config.yaml" ))
99
99
expect_message(
100
100
uninstall_precommit(scope = " repo" , root = tempdir ),
@@ -104,13 +104,13 @@ if (!on_cran()) {
104
104
105
105
test_that(" Can uninstall (userly)" , {
106
106
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 )
108
108
expect_error(
109
109
uninstall_precommit(scope = " user" , ask = " none" , root = tempdir ),
110
110
" installed with conda"
111
111
)
112
112
} else {
113
- tempdir <- local_test_setup(use_precommit = FALSE , quiet = FALSE )
113
+ tempdir <- local_test_setup(use_precommit = FALSE , quiet = FALSE , install_hooks = FALSE )
114
114
expect_message(
115
115
uninstall_precommit(scope = " user" , ask = " none" , root = tempdir ),
116
116
" Removed pre-commit from"
@@ -124,18 +124,18 @@ if (!on_cran()) {
124
124
125
125
test_that(" use_precommit fails when no user installation is found" , {
126
126
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" )
128
128
})
129
129
130
130
test_that(" can install pre-commit with remote config" , {
131
131
if (! not_conda()) {
132
132
expect_error(install_precommit(), NA )
133
133
}
134
- tempdir <- local_test_setup(quiet = FALSE )
134
+ tempdir <- local_test_setup(quiet = FALSE , install_hooks = FALSE )
135
135
expect_message(
136
136
use_precommit(
137
137
example_remote_config(),
138
- open = FALSE , force = TRUE , root = tempdir
138
+ open = FALSE , force = TRUE , install_hooks = FALSE , root = tempdir
139
139
),
140
140
" to get the latest"
141
141
)
@@ -145,14 +145,14 @@ if (!on_cran()) {
145
145
if (! not_conda()) {
146
146
expect_message(install_precommit(), " already installed" )
147
147
}
148
- tempdir <- local_test_setup(use_precommit = FALSE , quiet = FALSE )
148
+ tempdir <- local_test_setup(use_precommit = FALSE , quiet = FALSE , install_hooks = FALSE )
149
149
withr :: with_dir(
150
150
tempdir ,
151
151
{
152
152
withr :: defer(call_and_capture(" git" , " config --unset-all core.hooksPath" ))
153
153
call_and_capture(" git" , " config core.hooksPath .githooks" )
154
154
expect_error(
155
- use_precommit(open = FALSE , force = TRUE , root = tempdir ),
155
+ use_precommit(open = FALSE , force = TRUE , install_hooks = FALSE , root = tempdir ),
156
156
" stdout: [ERROR] Cowardly refusing to install hooks with `core.hooksPath` set." ,
157
157
fixed = TRUE
158
158
)
0 commit comments