Skip to content

Commit

Permalink
record upkeep year and use it
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Oct 8, 2024
1 parent b4e8477 commit 2be11f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 17 additions & 7 deletions R/upkeep.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Check warning on line 44 in R/upkeep.R

View check run for this annotation

Codecov / codecov/patch

R/upkeep.R#L44

Added line #L44 was not covered by tests
} else {
checklist <- upkeep_checklist(tr)
}
Expand Down Expand Up @@ -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"))

Check warning on line 126 in R/upkeep.R

View check run for this annotation

Codecov / codecov/patch

R/upkeep.R#L125-L126

Added lines #L125 - L126 were not covered by tests
}

# for mocking
Expand Down Expand Up @@ -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))
}
3 changes: 3 additions & 0 deletions tests/testthat/test-upkeep.R
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down

0 comments on commit 2be11f3

Please sign in to comment.