diff --git a/NEWS.md b/NEWS.md index 51f56b75d..80676838a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ * `pr_pull()`, `pr_push()` and friends now give more informative errors if usethis can't retrieve details about a remote (#1929, #2229). * `pr_resume()` (without a specific `branch`) and `pr_fetch()` (without a specific `number`) no longer error when a branch name contains curly braces (#2107, @jonthegeek). * `use_claude_code()` is an experimental helper to set up Claude Code in an R package in the same way as the tidyverse team (#2195). +* `use_course()`, `use_zip()`, and `use_github_action()` no longer emit download or pagination progress when the `usethis.quiet` option is `TRUE`. * `use_import_from()` works in packages using `roxygen2` 8.0.0 (#2226, report by @jonthegeek; fix by @JesseAlderliesten in #2234). * `use_pipe()` is now deprecated (@math-mcshane, #2124). * `use_readme_qmd()` creates a starter `README.qmd` with Quarto-flavored YAML frontmatter, analogous to `use_readme_rmd()` (#1671). Thanks @VisruthSK for getting the ball rolling. diff --git a/R/course.R b/R/course.R index 26083b7a4..ebe52d66a 100644 --- a/R/course.R +++ b/R/course.R @@ -260,7 +260,9 @@ tidy_download <- function(url, destdir = getwd()) { tmp <- file_temp("tidy-download-") h <- download_url(url, destfile = tmp) - cli::cat_line() + if (!is_quiet()) { + cli::cat_line() + } cd <- content_disposition(h) base_name <- make_filename(cd, fallback = path_file(url)) @@ -286,8 +288,10 @@ download_url <- function( n_tries = 3, retry_connecttimeout = 40L ) { - handle_options <- list(noprogress = FALSE, progressfunction = progress_fun) - curl::handle_setopt(handle, .list = handle_options) + if (!is_quiet()) { + handle_options <- list(noprogress = FALSE, progressfunction = progress_fun) + curl::handle_setopt(handle, .list = handle_options) + } we_should_retry <- function(i, n_tries, status) { if (i >= n_tries) { @@ -346,7 +350,13 @@ download_url <- function( invisible(handle) } -try_download <- function(url, destfile, quiet = FALSE, mode = "wb", handle) { +try_download <- function( + url, + destfile, + quiet = is_quiet(), + mode = "wb", + handle +) { tryCatch( curl::curl_download( url = url, diff --git a/R/github-actions.R b/R/github-actions.R index f5bd064a1..b1b206ebe 100644 --- a/R/github-actions.R +++ b/R/github-actions.R @@ -306,7 +306,8 @@ latest_release <- function(repo_spec = "https://github.com/r-lib/actions") { owner = spec_owner(parsed$repo_spec), repo = spec_repo(parsed$repo_spec), .api_url = parsed$host, - .limit = Inf + .limit = Inf, + .progress = !is_quiet() ) tag_names <- purrr::discard( map_chr(raw_releases, "tag_name"), diff --git a/tests/testthat/test-badge.R b/tests/testthat/test-badge.R index cfd8d7ba2..c917dadae 100644 --- a/tests/testthat/test-badge.R +++ b/tests/testthat/test-badge.R @@ -27,8 +27,8 @@ test_that("use_binder_badge() needs a github repository", { test_that("use_r_universe_badge() needs to know the owner", { skip_if_no_git_user() local_interactive(FALSE) - withr::local_options(usethis.quiet = FALSE) create_local_package() + withr::local_options(usethis.quiet = FALSE) expect_snapshot( error = TRUE, @@ -47,7 +47,7 @@ test_that("use_r_universe_badge() needs to know the owner", { transform = scrub_testpkg ) - use_git() + ui_silence(use_git()) use_git_remote("origin", "https://github.com/OWNER_ORIGIN/SCRUBBED.git") expect_snapshot( use_r_universe_badge(), diff --git a/tests/testthat/test-course.R b/tests/testthat/test-course.R index 3a91e1ebf..ec02ff2da 100644 --- a/tests/testthat/test-course.R +++ b/tests/testthat/test-course.R @@ -71,9 +71,7 @@ test_that("tidy_download() works", { gh_url <- "https://github.com/r-lib/rematch2/archive/main.zip" expected <- fs::path(tmp, "rematch2-main.zip") - capture.output( - out <- tidy_download(gh_url, destdir = tmp) - ) + out <- tidy_download(gh_url, destdir = tmp) expect_true(fs::file_exists(expected)) expect_identical(out, expected, ignore_attr = TRUE) expect_identical(attr(out, "content-type"), "application/zip")