Skip to content

Commit 9305b62

Browse files
Merge pull request #842 from lorenzwalthert/rc-1.6.2
Release 1.6.2
2 parents 0e41d88 + 76a1e09 commit 9305b62

File tree

11 files changed

+63
-71
lines changed

11 files changed

+63
-71
lines changed

.pre-commit-config.yaml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ repos:
88
hooks:
99
- id: style-files
1010
args: [--style_pkg=styler, --style_fun=tidyverse_style]
11-
exclude: 'tests/testthat/.*/.*\.R'
11+
exclude: >
12+
(?x)^(
13+
tests/testthat/.*/.*\.R(md)?|
14+
vignettes/customizing_styler\.Rmd|
15+
tests/testthat/public-api/xyzfile-rnw/random4\.Rnw|
16+
)$
1217
- id: roxygenize
1318
- id: use-tidy-description
1419
- id: spell-check
1520
exclude: >
1621
(?x)^(
17-
data/.*|
1822
\.github/.*\.yaml|
23+
data/.*|
24+
tests/testthat/.*|
1925
touchstone/config\.json|
2026
(.*/|)\.Rprofile|
2127
(.*/|)\.Renviron|
@@ -38,13 +44,31 @@ repos:
3844
)$
3945
- id: readme-rmd-rendered
4046
- id: parsable-R
47+
exclude: >
48+
(?x)^(
49+
tests/testthat/public-api/xyzaddin/addin_region-.*|
50+
tests/testmanual/addins/r-invalid\.R|
51+
tests/testthat/escaping/basic-escape-out\.R|
52+
tests/testthat/indention_operators/base_pipe_and_assignment-.*|
53+
tests/testthat/exception_handling/parser-error.R|
54+
)$
4155
- id: no-browser-statement
56+
exclude: >
57+
(?x)^(
58+
tests/testthat/public-api/xyzaddin/addin_region-.*|
59+
tests/testmanual/addins/r-invalid\.R|
60+
tests/testthat/escaping/basic-escape-out\.R|
61+
tests/testthat/indention_operators/base_pipe_and_assignment-.*|
62+
tests/testthat/exception_handling/parser-error.R|
63+
)$
4264
- id: deps-in-desc
4365
exclude: >
4466
(?x)^(
4567
touchstone/.*|
46-
tests/testthat/.*-in\.R(md)?|
47-
tests/testthat/.*-out\.R(md)?
68+
tests/testmanual/addins/r-invalid\.R|
69+
tests/testthat/escaping/basic-escape-out\.R|
70+
tests/testthat/rnw/011-conditional-eval-out\.Rnw|
71+
tests/testthat/.*\.R(md)?
4872
)$
4973
- repo: https://github.com/pre-commit/pre-commit-hooks
5074
rev: v4.0.1

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: styler
33
Title: Non-Invasive Pretty Printing of R Code
4-
Version: 1.6.1.9000
4+
Version: 1.6.2
55
Authors@R:
66
c(person(given = "Kirill",
77
family = "Müller",

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# styler 1.2
2+
3+
* clean up cache files older than one week (#842).
4+
15
# styler 1.6.1
26

37
* Files with `.Rmarkdown` extension are now recognized as an R markdown files in

R/nest.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ drop_cached_children <- function(pd) {
135135
#' @details
136136
#' Note that top-level comments **above** code have negative parents
137137
#' (the negative value of the parent of the code expression that follows after,
138-
#' a nother comment might be in the way though), all comments that are not top
138+
#' another comment might be in the way though), all comments that are not top
139139
#' level have positive ids. All comments for which no code follows afterwards
140140
#' have parent 0.
141141
#' @examples

R/utils-cache.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ cache_dir_default <- function() {
201201

202202
#' Create more specs
203203
#'
204-
#' Syntactic suggar for creating more specs. This is useful when we want to add
204+
#' Syntactic sugar for creating more specs. This is useful when we want to add
205205
#' more arguments (because we can search for this function in the source code).
206206
#' @keywords internal
207207
cache_more_specs <- function(include_roxygen_examples, base_indention) {

R/zzz.R

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,31 @@
88
styler.ignore_start = "# styler: off",
99
styler.ignore_stop = "# styler: on",
1010
styler.quiet = FALSE,
11-
styler.test_dir_writable = TRUE,
12-
styler.interactive_ask_remove_old_caches = TRUE
11+
styler.test_dir_writable = TRUE
1312
)
1413
toset <- !(names(op.styler) %in% names(op))
1514
if (any(toset)) options(op.styler[toset])
16-
remind_removing_old_cache()
15+
remove_cache_old_versions()
16+
remove_old_cache_files()
1717
invisible()
1818
}
1919

20-
#' Ask people to remove the cache
21-
#'
22-
#' The way RStudio Startup works does not allow o read the prompt for some
23-
#' reasons (https://stackoverflow.com/questions/55772436/readline-does-not-prompt-user-input-from-rprofile-site-in-rstudio)
24-
#' So we better don't use the prompt and issue a message only.
25-
#' @keywords internal
26-
remind_removing_old_cache <- function() {
27-
if (interactive() && getOption("styler.interactive_ask_remove_old_caches", TRUE)) {
28-
dirs <- list.dirs(R.cache::getCachePath("styler"), recursive = FALSE)
29-
if (length(dirs) < 1) {
30-
return()
31-
}
32-
dirs <- dirs[unname(sapply(dirs, function(x) length(list.files(x)) > 0))]
33-
package_versions <- package_version(basename(dirs), strict = FALSE)
34-
package_versions <- package_versions[!is.na(package_versions)]
35-
old_package_versions <- package_versions[package_versions < styler_version]
36-
if (length(old_package_versions) < 1) {
37-
return()
38-
}
20+
remove_old_cache_files <- function() {
21+
all_cached <- list.files(
22+
R.cache::getCachePath(c("styler", styler_version)),
23+
full.names = TRUE, recursive = TRUE
24+
)
25+
date_boundary <- Sys.time() - 60 * 60 * 24 * 6
26+
file.remove(
27+
all_cached[file.info(all_cached)$mtime < date_boundary]
28+
)
29+
}
30+
3931

40-
cmd <- glue::glue("styler::cache_clear(\"{basename(dirs)}\", ask = FALSE)") %>%
41-
paste0(collapse = "\n")
42-
cli::cli_alert_info(paste0(
43-
"You are using {{styler}} version {styler_version} but we found ",
44-
"caches for older versions of {{styler}}.\n",
45-
"You can delete them with the following commands:"
46-
))
47-
cat("\n")
48-
cli::cli_code(cmd)
49-
cat("\n")
50-
cli::cli_alert_info(
51-
paste(
52-
"We'll remind you every time you update {{styler}}.",
53-
"To suppress this prompt in the future:"
54-
)
55-
)
56-
cat("\n")
57-
cli::cli_code(
58-
'options("styler.interactive_ask_remove_old_caches" = FALSE)'
59-
)
60-
}
32+
remove_cache_old_versions <- function() {
33+
dirs <- list.dirs(R.cache::getCachePath("styler"), recursive = FALSE)
34+
old_package_dirs <- dirs[basename(dirs) != as.character(styler_version)]
35+
purrr::walk(old_package_dirs, function(dir) {
36+
unlink(dir, recursive = TRUE, force = TRUE)
37+
})
6138
}

cran-comments.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
This is a submission to fix a problem with persistent caching, reported by
2-
Prof Ripley on 07.09.2021, and invalid URLs, based on an email from Uwe Ligges
3-
on 17.09.2021.
1+
This is a re-submission to fix a problem with persistent caching. Note that
2+
all cached files are of size 0 and this is by design to keep the cache small.
3+
Hence, the cache will still have files of size 0, but we remove all files older
4+
than a week and remove all caches for versions of styler other than the one
5+
running as requested.
46

57
## Test environments
68

man/cache_more_specs.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/find_pos_id_to_keep.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/remind_removing_old_cache.Rd

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)