Skip to content

Commit ffac48e

Browse files
don't invalidate cache in the following situation:
- some files in R/ are changed but not staged. - non-staged changes are stashed away. - hooks run (save Sys.time()) - stashes are restored If the non-staged changes are in R/ or man/, the cache is invalidated because the restoring makes the modification time later than the hook run time. We avoid this by only checking the modification time of files that were staged
1 parent ef26f40 commit ffac48e

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# precommit v0.1.0.90001
2+
3+
- Roxygen hook cache only includes files that are part of the index and
4+
will hence be able to use the cache in cases it was previously invalidated
5+
without need (#171).
6+
17
# precommit v0.1.0
28

39
Initial CRAN release. See https://lorenzwalthert.github.io/precommit/.

inst/WORDLIST

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ EOF
2929
exlucded
3030
fs
3131
getOption
32+
getwd
3233
gh
3334
github
3435
gitignore
@@ -46,19 +47,22 @@ knitr
4647
lang
4748
Lifecycle
4849
lintr
50+
loadCache
4951
lorenz
5052
lorenzwalthert
5153
macOS
5254
magrittr
5355
maxkb
5456
md
5557
miniconda
58+
mtime
5659
navbar
5760
netlify
5861
nrow
5962
oneliner
6063
os
6164
overscope
65+
packageVersion
6266
params
6367
parsable
6468
pkgapi
@@ -89,6 +93,7 @@ roclet
8993
roclets
9094
ropenscilabs
9195
roxygen
96+
roxygenise
9297
roxygenize
9398
RoxygenNote
9499
Rprofile
@@ -99,11 +104,13 @@ Rr
99104
Rscript
100105
RStudio
101106
rstudioapi
107+
saveCache
102108
seealso
103109
stderr
104110
stdout
105111
stopifnot
106112
styler
113+
Sys
107114
testthat
108115
tidyverse
109116
travis
@@ -115,6 +122,7 @@ usr
115122
VignetteBuilder
116123
walthert
117124
Walthert
125+
wd
118126
withr
119127
wordlist
120128
writeLines

inst/bin/roxygenize

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ wd <- list(getwd())
3838
cache <- loadCache(key = wd, dirs = path_relative_cache)
3939

4040
if (!is.null(cache)) {
41-
candidates <- list.files(c("R", "man"), full.names = TRUE)
41+
candidates <- intersect(
42+
list.files(c("R", "man"), full.names = TRUE),
43+
arguments$files
44+
)
4245
all_files <- file.info(candidates)
4346
last_modified <- max(all_files$mtime)
4447
if (last_modified > cache[[1]]) {

0 commit comments

Comments
 (0)