Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

record upkeep year and use it for filtering checklist #2070

Merged
merged 11 commits into from
Oct 22, 2024
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
thomasp85 marked this conversation as resolved.
Show resolved Hide resolved
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) {
thomasp85 marked this conversation as resolved.
Show resolved Hide resolved
who <- if (tidy) "use_tidy_upkeep_issue()" else "use_upkeep_issue()"
check_is_package(who)

Expand All @@ -41,7 +41,7 @@

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 @@

#' @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
thomasp85 marked this conversation as resolved.
Show resolved Hide resolved
#' 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 @@
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))
}
7 changes: 4 additions & 3 deletions man/tidyverse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/use_upkeep_issue.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
Loading