diff --git a/NEWS.md b/NEWS.md index 311e2707d..b1c58551b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,14 +1,18 @@ # usethis (development version) +* `use_tidy_upkeep_issue()` now records the year it is being run in the + `Config/usethis/upkeep` field in DESCRIPTION. If this value exists it is + furthermore used to filter the checklist when making the issue. + ## Bug fixes and minor improvements * `use_package()` now decreases a package minimum version required when `min_version` is lower than what is currently specified in the DESCRIPTION file (@jplecavalier, #1957). - + * `use_data()` now uses serialization version 3 by default. (@laurabrianna, #2044) -* Reverse dependency checks are only suggested if they exist +* Reverse dependency checks are only suggested if they exist (#1817, @seankross). # usethis 3.0.0 diff --git a/R/upkeep.R b/R/upkeep.R index 0de6d48fb..2c4823fe0 100644 --- a/R/upkeep.R +++ b/R/upkeep.R @@ -16,13 +16,13 @@ #' @export #' @examples #' \dontrun{ -#' use_upkeep_issue(2023) +#' use_upkeep_issue() #' } use_upkeep_issue <- function(year = NULL) { make_upkeep_issue(year = year, tidy = FALSE) } -make_upkeep_issue <- function(year, tidy) { +make_upkeep_issue <- function(year, last_year, tidy) { who <- if (tidy) "use_tidy_upkeep_issue()" else "use_upkeep_issue()" check_is_package(who) @@ -41,7 +41,7 @@ make_upkeep_issue <- function(year, tidy) { gh <- gh_tr(tr) if (tidy) { - checklist <- tidy_upkeep_checklist(year, repo_spec = tr$repo_spec) + checklist <- tidy_upkeep_checklist(last_year, repo_spec = tr$repo_spec) } else { checklist <- upkeep_checklist(tr) } @@ -118,10 +118,12 @@ upkeep_checklist <- function(target_repo = NULL) { #' @export #' @rdname tidyverse -#' @param year Approximate year when you last touched this package. If `NULL`, -#' the default, will give you a full set of actions to perform. -use_tidy_upkeep_issue <- function(year = NULL) { - make_upkeep_issue(year = year, tidy = TRUE) +#' @param year Approximate year when you last touched this package. Default will +#' use the recorded year of the last upkeep issue or, if missing, show the full +#' checklist +use_tidy_upkeep_issue <- function(year = last_upkeep_year()) { + make_upkeep_issue(year = NULL, last_year = year, tidy = TRUE) + record_upkeep_year(format(Sys.Date(), "%Y")) } # for mocking @@ -327,3 +329,11 @@ has_old_cran_comments <- function() { file_exists(cc) && any(grepl("# test environment", readLines(cc), ignore.case = TRUE)) } + +last_upkeep_year <- function() { + as.integer(proj_desc()$get_field("Config/usethis/upkeep", 2000L)) +} + +record_upkeep_year <- function(year) { + desc <- proj_desc_field_update("Config/usethis/upkeep", as.character(year)) +} diff --git a/tests/testthat/test-upkeep.R b/tests/testthat/test-upkeep.R index f0da07051..c757d91ba 100644 --- a/tests/testthat/test-upkeep.R +++ b/tests/testthat/test-upkeep.R @@ -1,6 +1,9 @@ test_that("tidy upkeep bullets don't change accidentally", { create_local_package() use_mit_license() + expect_equal(last_upkeep_year(), 2000L) + record_upkeep_year(2022L) + expect_equal(last_upkeep_year(), 2022L) local_mocked_bindings( Sys.Date = function() as.Date("2023-01-01"),