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
28 changes: 21 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_date(Sys.Date())

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,15 @@
file_exists(cc) &&
any(grepl("# test environment", readLines(cc), ignore.case = TRUE))
}

last_upkeep_date <- function() {
as.Date(proj_desc()$get_field("Config/usethis/upkeep", "2000-01-01"), format = "%Y-%m-%d")
}

last_upkeep_year <- function() {
as.integer(format(last_upkeep_date(), "%Y"))
}

record_upkeep_date <- function(date) {
desc <- proj_desc_field_update("Config/usethis/upkeep", format(date, "%Y-%m-%d"))
}
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.

47 changes: 0 additions & 47 deletions tests/testthat/_snaps/upkeep.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,50 +60,3 @@

<sup>Created on 2023-01-01 with `usethis::use_tidy_upkeep_issue()`, using [usethis v1.1.0](https://usethis.r-lib.org)</sup>

# upkeep bullets don't change accidentally
thomasp85 marked this conversation as resolved.
Show resolved Hide resolved

Code
writeLines(upkeep_checklist())
Output
* [ ] `usethis::use_readme_rmd()`
* [ ] `usethis::use_github_links()`
* [ ] `usethis::use_pkgdown_github_pages()`
* [ ] `usethis::use_tidy_description()`
* [ ] `usethis::use_package_doc()`
Consider letting usethis manage your `@importFrom` directives here. `usethis::use_import_from()` is handy for this.
* [ ] `usethis::use_testthat()`. Learn more about testing at <https://r-pkgs.org/tests.html>
* [ ] Align the names of `R/` files and `test/` files for workflow happiness. The docs for `usethis::use_r()` include a helpful script. `usethis::rename_files()` may be be useful.
* [ ] `usethis::use_code_of_conduct()`
* [ ] Add alt-text to pictures, plots, etc; see <https://posit.co/blog/knitr-fig-alt/> for examples

Set up or update GitHub Actions. \
Updating workflows to the latest version will often fix troublesome actions:
* [ ] `usethis::use_github_action('check-standard')`

<sup>Created on 2023-01-01 with `usethis::use_upkeep_issue()`, using [usethis v1.1.0](https://usethis.r-lib.org)</sup>

---

Code
writeLines(checklist)
Output
* [ ] `usethis::use_readme_rmd()`
* [ ] `usethis::use_github_links()`
* [ ] `usethis::use_pkgdown_github_pages()`
* [ ] `usethis::use_tidy_description()`
* [ ] `usethis::use_package_doc()`
Consider letting usethis manage your `@importFrom` directives here. `usethis::use_import_from()` is handy for this.
* [ ] `usethis::use_testthat(3)` and upgrade to 3e, [testthat 3e vignette](https://testthat.r-lib.org/articles/third-edition.html)
* [ ] Align the names of `R/` files and `test/` files for workflow happiness. The docs for `usethis::use_r()` include a helpful script. `usethis::rename_files()` may be be useful.
* [ ] Consider changing default branch from `master` to `main`
* [ ] Remove description of test environments from `cran-comments.md`.
See `usethis::use_cran_comments()`.
* [ ] Add alt-text to pictures, plots, etc; see <https://posit.co/blog/knitr-fig-alt/> for examples

Set up or update GitHub Actions. \
Updating workflows to the latest version will often fix troublesome actions:
* [ ] `usethis::use_github_action('check-standard')`
* [ ] `usethis::use_github_action('test-coverage')`

<sup>Created on 2023-01-01 with `usethis::use_upkeep_issue()`, using [usethis v1.1.0](https://usethis.r-lib.org)</sup>

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_date(as.Date("2022-04-04"))
expect_equal(last_upkeep_year(), 2022L)

local_mocked_bindings(
Sys.Date = function() as.Date("2023-01-01"),
Expand Down
Loading