Skip to content

Commit a9afa2c

Browse files
thomasp85jennybc
andauthored
record upkeep year and use it for filtering checklist (#2070)
* record upkeep year and use it * redoc * record full date in DESCRIPTION * fix tests * rerun tests * use last-upkeep as field name * rename arg * Tweak documentation; indentation * Really embrace last_upkeep as being clearer about what it means * Have one test for full list + another for "since last upkeep" --------- Co-authored-by: Jenny Bryan <[email protected]>
1 parent 0c43d57 commit a9afa2c

File tree

7 files changed

+106
-26
lines changed

7 files changed

+106
-26
lines changed

NEWS.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# usethis (development version)
22

3+
* `use_tidy_upkeep_issue()` now records the year it is being run in the
4+
`Config/usethis/upkeep` field in DESCRIPTION. If this value exists it is
5+
furthermore used to filter the checklist when making the issue.
6+
37
## Bug fixes and minor improvements
48

59
* `use_package()` now decreases a package minimum version required when
610
`min_version` is lower than what is currently specified in the DESCRIPTION
711
file (@jplecavalier, #1957).
8-
12+
913
* `use_data()` now uses serialization version 3 by default. (@laurabrianna, #2044)
1014

11-
* Reverse dependency checks are only suggested if they exist
15+
* Reverse dependency checks are only suggested if they exist
1216
(#1817, @seankross).
1317

1418
# usethis 3.0.0

R/tidyverse.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
#' tidyverse conventions around GitHub issue label names and colours.
4545
#'
4646
#' * `use_tidy_upkeep_issue()` creates an issue containing a checklist of
47-
#' actions to bring your package up to current tidyverse standards.
47+
#' actions to bring your package up to current tidyverse standards. Also
48+
#' records the current date in the `Config/usethis/last-upkeep` field in
49+
#' `DESCRIPTION`.
4850
#'
4951
#' * `use_tidy_logo()` calls `use_logo()` on the appropriate hex sticker PNG
5052
#' file at <https://github.com/rstudio/hex-stickers>.

R/upkeep.R

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
#' @export
1717
#' @examples
1818
#' \dontrun{
19-
#' use_upkeep_issue(2023)
19+
#' use_upkeep_issue()
2020
#' }
2121
use_upkeep_issue <- function(year = NULL) {
2222
make_upkeep_issue(year = year, tidy = FALSE)
2323
}
2424

25-
make_upkeep_issue <- function(year, tidy) {
25+
make_upkeep_issue <- function(year, last_upkeep, tidy) {
2626
who <- if (tidy) "use_tidy_upkeep_issue()" else "use_upkeep_issue()"
2727
check_is_package(who)
2828

@@ -41,7 +41,7 @@ make_upkeep_issue <- function(year, tidy) {
4141

4242
gh <- gh_tr(tr)
4343
if (tidy) {
44-
checklist <- tidy_upkeep_checklist(year, repo_spec = tr$repo_spec)
44+
checklist <- tidy_upkeep_checklist(last_upkeep, repo_spec = tr$repo_spec)
4545
} else {
4646
checklist <- upkeep_checklist(tr)
4747
}
@@ -118,31 +118,33 @@ upkeep_checklist <- function(target_repo = NULL) {
118118

119119
#' @export
120120
#' @rdname tidyverse
121-
#' @param year Approximate year when you last touched this package. If `NULL`,
122-
#' the default, will give you a full set of actions to perform.
123-
use_tidy_upkeep_issue <- function(year = NULL) {
124-
make_upkeep_issue(year = year, tidy = TRUE)
121+
#' @param last_upkeep Year of last upkeep. By default, the
122+
#' `Config/usethis/last-upkeep` field in `DESCRIPTION` is consulted for this, if
123+
#' it's defined. If there's no information on the last upkeep, the issue will
124+
#' contain the full checklist.
125+
use_tidy_upkeep_issue <- function(last_upkeep = last_upkeep_year()) {
126+
make_upkeep_issue(year = NULL, last_upkeep = last_upkeep, tidy = TRUE)
127+
record_upkeep_date(Sys.Date())
125128
}
126129

127130
# for mocking
128131
Sys.Date <- NULL
129132

130-
tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
133+
tidy_upkeep_checklist <- function(last_upkeep = last_upkeep_year(),
134+
repo_spec = "OWNER/REPO") {
131135
desc <- proj_desc()
132136

133137
posit_pkg <- is_posit_pkg()
134138
posit_person_ok <- is_posit_person_canonical()
135139

136-
year <- year %||% 2000
137-
138140
bullets <- c(
139141
"### To begin",
140142
"",
141143
todo('`pr_init("upkeep-{format(Sys.Date(), "%Y-%m")}")`'),
142144
""
143145
)
144146

145-
if (year <= 2000) {
147+
if (last_upkeep <= 2000) {
146148
bullets <- c(
147149
bullets,
148150
"### Pre-history",
@@ -157,7 +159,7 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
157159
""
158160
)
159161
}
160-
if (year <= 2020) {
162+
if (last_upkeep <= 2020) {
161163
bullets <- c(
162164
bullets,
163165
"### 2020",
@@ -168,7 +170,7 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
168170
""
169171
)
170172
}
171-
if (year <= 2021) {
173+
if (last_upkeep <= 2021) {
172174
bullets <- c(
173175
bullets,
174176
"### 2021",
@@ -178,7 +180,7 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
178180
""
179181
)
180182
}
181-
if (year <= 2022) {
183+
if (last_upkeep <= 2022) {
182184
bullets <- c(
183185
bullets,
184186
"### 2022",
@@ -191,7 +193,7 @@ tidy_upkeep_checklist <- function(year = NULL, repo_spec = "OWNER/REPO") {
191193
)
192194
}
193195

194-
if (year <= 2023) {
196+
if (last_upkeep <= 2023) {
195197
bullets <- c(
196198
bullets,
197199
"### 2023",
@@ -326,3 +328,18 @@ has_old_cran_comments <- function() {
326328
file_exists(cc) &&
327329
any(grepl("# test environment", readLines(cc), ignore.case = TRUE))
328330
}
331+
332+
last_upkeep_date <- function() {
333+
as.Date(
334+
proj_desc()$get_field("Config/usethis/last-upkeep", "2000-01-01"),
335+
format = "%Y-%m-%d"
336+
)
337+
}
338+
339+
last_upkeep_year <- function() {
340+
as.integer(format(last_upkeep_date(), "%Y"))
341+
}
342+
343+
record_upkeep_date <- function(date) {
344+
proj_desc_field_update("Config/usethis/last-upkeep", format(date, "%Y-%m-%d"))
345+
}

man/tidyverse.Rd

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/use_upkeep_issue.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.

tests/testthat/_snaps/upkeep.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Output
66
### To begin
77
8-
* [ ] `pr_init("upkeep-2023-01")`
8+
* [ ] `pr_init("upkeep-2025-01")`
99
1010
### Pre-history
1111
@@ -58,7 +58,41 @@
5858
* [ ] `devtools::build_readme()`
5959
* [ ] [Re-publish released site](https://pkgdown.r-lib.org/dev/articles/how-to-update-released-site.html) if needed
6060
61-
<sup>Created on 2023-01-01 with `usethis::use_tidy_upkeep_issue()`, using [usethis v1.1.0](https://usethis.r-lib.org)</sup>
61+
<sup>Created on 2025-01-01 with `usethis::use_tidy_upkeep_issue()`, using [usethis v1.1.0](https://usethis.r-lib.org)</sup>
62+
63+
# tidy upkeep omits bullets present in last_upkeep
64+
65+
Code
66+
writeLines(tidy_upkeep_checklist())
67+
Output
68+
### To begin
69+
70+
* [ ] `pr_init("upkeep-2025-01")`
71+
72+
### 2023
73+
74+
* [ ] Update email addresses *@rstudio.com -> *@posit.co
75+
* [ ] Update copyright holder in DESCRIPTION: `person("Posit Software, PBC", role = c("cph", "fnd"))`
76+
* [ ] Run `devtools::document()` to re-generate package-level help topic with DESCRIPTION changes
77+
* [ ] `usethis::use_tidy_logo(); pkgdown::build_favicons(overwrite = TRUE)`
78+
* [ ] `usethis::use_tidy_coc()`
79+
* [ ] Use `pak::pak("OWNER/REPO")` in README
80+
* [ ] Consider running `usethis::use_tidy_dependencies()` and/or replace compat files with `use_standalone()`
81+
* [ ] Use cli errors or [file an issue](new) if you don't have time to do it now
82+
* [ ] `usethis::use_standalone("r-lib/rlang", "types-check")` instead of home grown argument checkers;
83+
or [file an issue](new) if you don't have time to do it now
84+
* [ ] Add alt-text to pictures, plots, etc; see https://posit.co/blog/knitr-fig-alt/ for examples
85+
86+
### To finish
87+
88+
* [ ] `usethis::use_mit_license()`
89+
* [ ] `usethis::use_package("R", "Depends", "4.0")`
90+
* [ ] `usethis::use_tidy_description()`
91+
* [ ] `usethis::use_tidy_github_actions()`
92+
* [ ] `devtools::build_readme()`
93+
* [ ] [Re-publish released site](https://pkgdown.r-lib.org/dev/articles/how-to-update-released-site.html) if needed
94+
95+
<sup>Created on 2025-01-01 with `usethis::use_tidy_upkeep_issue()`, using [usethis v1.1.0](https://usethis.r-lib.org)</sup>
6296

6397
# upkeep bullets don't change accidentally
6498

tests/testthat/test-upkeep.R

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
test_that("tidy upkeep bullets don't change accidentally", {
22
create_local_package()
33
use_mit_license()
4+
expect_equal(last_upkeep_year(), 2000L)
45

56
local_mocked_bindings(
6-
Sys.Date = function() as.Date("2023-01-01"),
7+
Sys.Date = function() as.Date("2025-01-01"),
8+
usethis_version = function() "1.1.0",
9+
author_has_rstudio_email = function() TRUE,
10+
is_posit_pkg = function() TRUE,
11+
is_posit_person_canonical = function() FALSE
12+
)
13+
14+
expect_snapshot(writeLines(tidy_upkeep_checklist()))
15+
})
16+
17+
test_that("tidy upkeep omits bullets present in last_upkeep", {
18+
create_local_package()
19+
use_mit_license()
20+
expect_equal(last_upkeep_year(), 2000L)
21+
record_upkeep_date(as.Date("2023-04-04"))
22+
expect_equal(last_upkeep_year(), 2023L)
23+
24+
local_mocked_bindings(
25+
Sys.Date = function() as.Date("2025-01-01"),
726
usethis_version = function() "1.1.0",
827
author_has_rstudio_email = function() TRUE,
928
is_posit_pkg = function() TRUE,

0 commit comments

Comments
 (0)