Skip to content

Commit

Permalink
Merged upstream/main into olivroy-challenge-uncommited-tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Aug 15, 2024
2 parents 9841741 + 00552db commit 54e13c1
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 5 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Imports:
rprojroot (>= 1.2),
rstudioapi,
stats,
tools,
utils,
whisker,
withr (>= 2.3.0),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# usethis (development version)

* Reverse dependency checks are only suggested if they exist
(#1817, @seankross).

# usethis 3.0.0

## Transition to cli package for UI
Expand Down
4 changes: 2 additions & 2 deletions R/course.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#'
#' * GitHub repo spec: "OWNER/REPO". Equivalent to
#' `https://github.com/OWNER/REPO/DEFAULT_BRANCH.zip`.
#' * bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy".
#' * bit.ly, pos.it, or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz", "pos.it/foofy" or "rstd.io/foofy".
#' The instructor must then arrange for the shortlink to point to a valid
#' download URL for the target ZIP file. The helper
#' [create_download_url()] helps to create such URLs for GitHub, DropBox,
Expand Down Expand Up @@ -492,7 +492,7 @@ normalize_url <- function(url) {
}

is_shortlink <- function(url) {
shortlink_hosts <- c("rstd\\.io", "bit\\.ly")
shortlink_hosts <- c("rstd\\.io", "bit\\.ly", "pos\\.it")
any(map_lgl(shortlink_hosts, grepl, x = url))
}

Expand Down
8 changes: 7 additions & 1 deletion R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,14 @@ gh_milestone_number <- function(target_repo, version, state = "open") {
numbers[match(paste0("v", version), titles)]
}

# Get revdeps for current package
get_revdeps <- function() {
pkg <- proj_desc()$get_field("Package")
tools::package_dependencies(pkg, which = "all", reverse = TRUE)[[pkg]]
}

release_revdepcheck <- function(on_cran = TRUE, is_posit_pkg = TRUE, env = NULL) {
if (!on_cran) {
if (!on_cran || length(get_revdeps()) == 0) {
return()
}

Expand Down
2 changes: 1 addition & 1 deletion man/zip-utils.Rd

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

35 changes: 35 additions & 0 deletions tests/testthat/_snaps/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,38 @@
* [ ] `usethis::use_news_md()`
* [ ] Share on social media

# no revdep release bullets when there are no revdeps

Code
writeLines(release_checklist("1.0.0", on_cran = TRUE))
Output
Prepare for release:
* [ ] `git pull`
* [ ] Check [current CRAN check results](https://cran.rstudio.org/web/checks/check_results_{TESTPKG}.html)
* [ ] `usethis::use_news_md()`
* [ ] [Polish NEWS](https://style.tidyverse.org/news.html#news-release)
* [ ] `usethis::use_github_links()`
* [ ] `urlchecker::url_check()`
* [ ] `devtools::check(remote = TRUE, manual = TRUE)`
* [ ] `devtools::check_win_devel()`
* [ ] Update `cran-comments.md`
* [ ] `git push`
* [ ] Draft blog post
Submit to CRAN:
* [ ] `usethis::use_version('major')`
* [ ] `devtools::submit_cran()`
* [ ] Approve email
Wait for CRAN...
* [ ] Accepted :tada:
* [ ] Finish & publish blog post
* [ ] Add link to blog post in pkgdown news menu
* [ ] `usethis::use_github_release()`
* [ ] `usethis::use_dev_version(push = TRUE)`
* [ ] `usethis::use_news_md()`
* [ ] Share on social media

25 changes: 24 additions & 1 deletion tests/testthat/test-release.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ test_that("release bullets don't change accidentally", {
withr::local_options(usethis.description = NULL)
create_local_package()

local_mocked_bindings(
get_revdeps = function() "usethis"
)

# First release
expect_snapshot(
writeLines(release_checklist("0.1.0", on_cran = FALSE)),
Expand Down Expand Up @@ -52,6 +56,10 @@ test_that("construct correct revdep bullet", {
create_local_package()
env <- env(release_extra_revdeps = function() c("waldo", "testthat"))

local_mocked_bindings(
get_revdeps = function() "usethis"
)

expect_snapshot({
release_revdepcheck(on_cran = FALSE)
release_revdepcheck(on_cran = TRUE, is_posit_pkg = FALSE)
Expand All @@ -64,7 +72,8 @@ test_that("RStudio-ness detection works", {
withr::local_options(usethis.description = NULL)
create_local_package()
local_mocked_bindings(
tidy_minimum_r_version = function() numeric_version("3.6")
tidy_minimum_r_version = function() numeric_version("3.6"),
get_revdeps = function() "usethis"
)

expect_false(is_posit_pkg())
Expand Down Expand Up @@ -245,3 +254,17 @@ test_that("default_cran_mirror() is respects set value but falls back to cloud",
withr::local_options(repos = c())
expect_equal(default_cran_mirror(), c(CRAN = "https://cloud.r-project.org"))
})

test_that("no revdep release bullets when there are no revdeps", {
withr::local_options(usethis.description = NULL)
create_local_package()

local_mocked_bindings(
get_revdeps = function() NULL
)

expect_snapshot(
writeLines(release_checklist("1.0.0", on_cran = TRUE)),
transform = scrub_testpkg
)
})

0 comments on commit 54e13c1

Please sign in to comment.