Skip to content

Commit 9841741

Browse files
committed
Merged upstream/main into olivroy-challenge-uncommited-tweaks
2 parents 2e59179 + 0e20668 commit 9841741

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+799
-339
lines changed

.github/workflows/R-CMD-check.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
pull_request:
1111
branches: [main, master]
1212

13-
name: R-CMD-check
13+
name: R-CMD-check.yaml
1414

1515
permissions: read-all
1616

@@ -27,8 +27,8 @@ jobs:
2727
- {os: macos-latest, r: 'release'}
2828

2929
- {os: windows-latest, r: 'release'}
30-
# use 4.1 to check with rtools40's older compiler
31-
- {os: windows-latest, r: '4.1'}
30+
# use 4.0 or 4.1 to check with rtools40's older compiler
31+
- {os: windows-latest, r: 'oldrel-4'}
3232

3333
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
3434
- {os: ubuntu-latest, r: 'release'}

.github/workflows/pkgdown.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
types: [published]
1010
workflow_dispatch:
1111

12-
name: pkgdown
12+
name: pkgdown.yaml
1313

1414
permissions: read-all
1515

.github/workflows/pr-commands.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
issue_comment:
55
types: [created]
66

7-
name: Commands
7+
name: pr-commands.yaml
88

99
permissions: read-all
1010

@@ -15,6 +15,8 @@ jobs:
1515
runs-on: ubuntu-latest
1616
env:
1717
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
18+
permissions:
19+
contents: write
1820
steps:
1921
- uses: actions/checkout@v4
2022

@@ -52,6 +54,8 @@ jobs:
5254
runs-on: ubuntu-latest
5355
env:
5456
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
57+
permissions:
58+
contents: write
5559
steps:
5660
- uses: actions/checkout@v4
5761

.github/workflows/test-coverage.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77
branches: [main, master]
88

9-
name: test-coverage
9+
name: test-coverage.yaml
1010

1111
permissions: read-all
1212

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: usethis
22
Title: Automate Package and Project Setup
3-
Version: 2.2.3.9000
3+
Version: 3.0.0.9000
44
Authors@R: c(
55
person("Hadley", "Wickham", , "[email protected]", role = "aut",
66
comment = c(ORCID = "0000-0003-4757-117X")),

NEWS.md

+41-30
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,8 @@
11
# usethis (development version)
22

3-
* `use_test_helper()` is a new function to create a test helper file (@olivroy, #1822).
3+
# usethis 3.0.0
44

5-
* `use_cpp11()` makes it easier to update `NAMESPACE` (@pachadotdev, #1921).
6-
7-
* `pr_merge_main()` now offers the choice to not open the files with merge conflicts (@olivroy, #1720).
8-
9-
* `edit_rstudio_snippets()` now accepts yaml snippets (@olivroy, #1941).
10-
11-
* `use_standalone()` inserts an improved header that includes the code needed to
12-
update the standalone file (@krlmlr, #1903).
13-
14-
* `use_release_issue()` and `use_upkeep()` behave better when the user has a
15-
fork. The user is asked just once to choose between `origin` and `upstream` as
16-
the target repo (#2023).
17-
18-
* The README templates now recommend [pak](https://pak.r-lib.org) instead of
19-
devtools for package installation (@olivroy, #1723).
20-
21-
* `use_github()` now knows that you can reuse the name of an earlier repo that
22-
has since been renamed (@ateucher, #1893).
23-
24-
* `use_git()` no longer asks if you want to restart RStudio when using Positron.
25-
26-
* `use_test()` and `use_r()` now work when you are in `tests/testthat/_snaps/{foo}.md` (@olivroy, #1988).
27-
28-
* The URLs baked into the badge generated by `use_coverage(type = "codecov")`
29-
no longer specify a branch (#2008).
5+
## Transition to cli package for UI
306

317
* The `ui_*()` functions have been marked as
328
[superseded](https://lifecycle.r-lib.org/articles/stages.html#superseded).
@@ -37,13 +13,9 @@
3713
superior option.
3814
There is a cli vignette about how to make this transition:
3915
`vignette("usethis-ui", package = "cli")`.
40-
4116
usethis no longer uses the `ui_*()` functions internally, in favor of new
4217
cli-based helpers that are not exported.
4318

44-
* `usethis::use_version()` now tolerates empty / blank lines preceding the
45-
first section title in the package NEWS file. (#1976)
46-
4719
## Deprecated function and argument removal
4820

4921
We are removing functions and arguments that were deprecated as of usethis
@@ -81,6 +53,45 @@ Function arguments that are removed:
8153
* `use_github_links(auth_token =, host =)`
8254
* `use_github_release(host =, auth_token =)`
8355

56+
## Other changes
57+
58+
* `use_zip()` and `use_course()` are equipped to handle a ZIP where the parent
59+
folder is implicit (@burnsal, #1961).
60+
61+
* `use_test_helper()` is a new function to create a test helper file
62+
(@olivroy, #1822).
63+
64+
* `use_cpp11()` makes it easier to update `NAMESPACE` (@pachadotdev, #1921).
65+
66+
* `pr_merge_main()` now offers the choice to not open the files with merge
67+
conflicts (@olivroy, #1720).
68+
69+
* `edit_rstudio_snippets()` now accepts yaml snippets (@olivroy, #1941).
70+
71+
* `use_standalone()` inserts an improved header that includes the code needed to
72+
update the standalone file (@krlmlr, #1903).
73+
74+
* `use_release_issue()` and `use_upkeep_issue()` behave better when the user has
75+
a fork. The user is asked just once to choose between `origin` and `upstream`
76+
as the target repo (#2023).
77+
78+
* The README templates now recommend [pak](https://pak.r-lib.org) instead of
79+
devtools for package installation (@olivroy, #1723).
80+
81+
* `use_github()` now knows that you can reuse the name of an earlier repo that
82+
has since been renamed (@ateucher, #1893).
83+
84+
* `use_git()` no longer asks if you want to restart RStudio when using Positron.
85+
86+
* `use_test()` and `use_r()` now work when you are in
87+
`tests/testthat/_snaps/{foo}.md` (@olivroy, #1988).
88+
89+
* The URLs baked into the badge generated by `use_coverage(type = "codecov")`
90+
are updated and no longer specify a branch(#2008).
91+
92+
* `usethis::use_version()` now tolerates empty lines preceding the
93+
first section title in the package NEWS file. (#1976)
94+
8495
# usethis 2.2.3
8596

8697
* Patch release with changes to `.Rd` files requested by CRAN.

R/badge.R

-10
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,6 @@ use_posit_cloud_badge <- function(url) {
165165
invisible(TRUE)
166166
}
167167

168-
#' @rdname badges
169-
#' @export
170-
use_rscloud_badge <- function(url) {
171-
lifecycle::deprecate_warn(
172-
"2.2.0", "use_rscloud_badge()",
173-
"use_posit_cloud_badge()"
174-
)
175-
use_posit_cloud_badge(url)
176-
}
177-
178168
has_badge <- function(href) {
179169
readme_path <- proj_path("README.md")
180170
if (!file_exists(readme_path)) {

R/browse.R

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#' DESCRIPTION file is sought first in the local package library and then
1010
#' on CRAN.
1111
#' * Fixed templates:
12-
#' - Travis CI: `https://travis-ci.{EXT}/{OWNER}/{PACKAGE}`
1312
#' - Circle CI: `https://circleci.com/gh/{OWNER}/{PACKAGE}`
1413
#' - CRAN landing page: `https://cran.r-project.org/package={PACKAGE}`
1514
#' - GitHub mirror of a CRAN package: `https://github.com/cran/{PACKAGE}`
@@ -29,8 +28,6 @@
2928
#' issue.
3029
#' * `browse_github_pulls()`: Visits the GitHub Pull Request index or one
3130
#' specific pull request.
32-
#' * `browse_travis()`: Visits the project's page on
33-
#' [Travis CI](https://www.travis-ci.com/).
3431
#' * `browse_circleci()`: Visits the project's page on
3532
#' [Circle CI](https://circleci.com).
3633
#' * `browse_cran()`: Visits the package on CRAN, via the canonical URL.

R/course.R

+25-23
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#' @param url Link to a ZIP file containing the materials. To reduce the chance
1212
#' of typos in live settings, these shorter forms are accepted:
1313
#'
14-
#' * GitHub repo spec: "OWNER/REPO". Equivalent to
15-
#' `https://github.com/OWNER/REPO/DEFAULT_BRANCH.zip`.
16-
#' * bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy".
17-
#' The instructor must then arrange for the shortlink to point to a valid
18-
#' download URL for the target ZIP file. The helper
19-
#' [create_download_url()] helps to create such URLs for GitHub, DropBox,
20-
#' and Google Drive.
14+
#' * GitHub repo spec: "OWNER/REPO". Equivalent to
15+
#' `https://github.com/OWNER/REPO/DEFAULT_BRANCH.zip`.
16+
#' * bit.ly or rstd.io shortlinks: "bit.ly/xxx-yyy-zzz" or "rstd.io/foofy".
17+
#' The instructor must then arrange for the shortlink to point to a valid
18+
#' download URL for the target ZIP file. The helper
19+
#' [create_download_url()] helps to create such URLs for GitHub, DropBox,
20+
#' and Google Drive.
2121
#' @param destdir Destination for the new folder. Defaults to the location
2222
#' stored in the global option `usethis.destdir`, if defined, or to the user's
2323
#' Desktop or similarly conspicuous place otherwise.
@@ -360,15 +360,15 @@ tidy_unzip <- function(zipfile, cleanup = FALSE) {
360360
## DropBox ZIP files often include lots of hidden R, RStudio, and Git files
361361
filenames <- filenames[keep_lgl(filenames)]
362362

363-
td <- top_directory(filenames)
364-
loose_parts <- is.na(td)
365-
366-
if (loose_parts) {
363+
parents <- path_before_slash(filenames)
364+
unique_parents <- unique(parents)
365+
if (length(unique_parents) == 1 && unique_parents != "") {
366+
target <- path(base_path, unique_parents)
367+
utils::unzip(zipfile, files = filenames, exdir = base_path)
368+
} else {
369+
# there is no parent; archive contains loose parts
367370
target <- path_ext_remove(zipfile)
368371
utils::unzip(zipfile, files = filenames, exdir = target)
369-
} else {
370-
target <- path(base_path, td)
371-
utils::unzip(zipfile, files = filenames, exdir = base_path)
372372
}
373373
ui_bullets(c(
374374
"v" = "Unpacking ZIP file into {.path {pth(target, base_path)}}
@@ -398,7 +398,7 @@ tidy_unzip <- function(zipfile, cleanup = FALSE) {
398398
}
399399
}
400400

401-
invisible(target)
401+
invisible(unclass(target))
402402
}
403403

404404
#' @rdname use_course_details
@@ -525,15 +525,17 @@ keep_lgl <- function(file,
525525
!grepl(ignores, file, perl = TRUE)
526526
}
527527

528-
top_directory <- function(filenames) {
529-
in_top <- path_dir(filenames) == "."
530-
unique_top <- unique(filenames[in_top])
531-
is_directory <- grepl("/$", unique_top)
532-
if (length(unique_top) > 1 || !is_directory) {
533-
NA_character_
534-
} else {
535-
unique_top
528+
path_before_slash <- function(filepath) {
529+
f <- function(x) {
530+
parts <- strsplit(x, "/", fixed = TRUE)[[1]]
531+
if (length(parts) > 1 || grepl("/", x)) {
532+
parts[1]
533+
} else {
534+
""
535+
}
536536
}
537+
purrr::map_chr(filepath, f)
538+
537539
}
538540

539541
content_type <- function(h) {

R/coverage.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use_covr_ignore <- function(files) {
4444
}
4545

4646
use_codecov_badge <- function(repo_spec) {
47-
url <- glue("https://codecov.io/gh/{repo_spec}")
47+
url <- glue("https://app.codecov.io/gh/{repo_spec}")
4848
img <- glue("https://codecov.io/gh/{repo_spec}/graph/badge.svg")
4949
use_badge("Codecov test coverage", url, img)
5050
}

R/git.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ git_sitrep <- function(tool = c("git", "github"),
357357
if (!vaccinated) {
358358
ui_bullets(c("i" = "See {.fun usethis::git_vaccinate} to learn more."))
359359
}
360-
kv_line("Default Git protocol", git_protocol())
360+
kv_line("Default Git protocol", ui_silence(git_protocol()))
361361
kv_line("Default initial branch name", init_default_branch)
362362
}
363363

R/github-actions.R

+8-2
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,12 @@ use_github_action <- function(name = NULL,
124124
ui_bullets(c("_" = "Learn more at {.url {readme}}."))
125125
}
126126

127-
badge <- badge %||% is_check_action(url)
128-
if (badge) {
127+
if (badge %||% is_check_action(url)) {
129128
use_github_actions_badge(path_file(save_as))
130129
}
130+
if (badge %||% is_coverage_action(url)) {
131+
use_codecov_badge(target_repo_spec())
132+
}
131133

132134
invisible(new)
133135
}
@@ -167,6 +169,10 @@ is_check_action <- function(url) {
167169
grepl("^check-", path_file(url))
168170
}
169171

172+
is_coverage_action <- function(url) {
173+
grepl("test-coverage", path_file(url))
174+
}
175+
170176
#' Generates a GitHub Actions badge
171177
#'
172178
#' Generates a GitHub Actions badge and that's all. This exists primarily for

R/github-labels.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ tidy_label_descriptions <- function() {
301301
"good first issue :heart:" = "good issue for first-time contributors",
302302
"help wanted :heart:" = "we'd love your help!",
303303
"breaking change :skull_and_crossbones:" = "API change likely to affect existing code",
304-
"tidy-dev-day :nerd_face:" = "Tidyverse Developer Day rstd.io/tidy-dev-day"
304+
"tidy-dev-day :nerd_face:" = "Tidyverse Developer Day"
305305
)
306306
}
307307

R/issue.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#' by the tidyverse team.
88
#'
99
#' * `issue_close_community()` closes an issue, because it's not a bug report or
10-
#' feature request, and points the author towards RStudio Community as a
11-
#' better place to discuss usage (<https://community.rstudio.com>).
10+
#' feature request, and points the author towards Posit Community as a
11+
#' better place to discuss usage (<https://forum.posit.co>).
1212
#'
1313
#' * `issue_reprex_needed()` labels the issue with the "reprex" label and
1414
#' gives the author some advice about what is needed.

R/pipe.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' Use magrittr's pipe in your package
22
#'
33
#' Does setup necessary to use magrittr's pipe operator, `%>%` in your package.
4-
#' This function requires the use roxygen.
4+
#' This function requires the use of \pkg{roxygen2}.
55
#' * Adds magrittr to "Imports" in `DESCRIPTION`.
66
#' * Imports the pipe operator specifically, which is necessary for internal
77
#' use.

R/pr.R

+1
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ pr_forget <- function() pr_clean(mode = "forget")
532532
pr_clean <- function(number = NULL,
533533
target = c("source", "primary"),
534534
mode = c("finish", "forget")) {
535+
withr::defer(rstudio_git_tickle())
535536
mode <- match.arg(mode)
536537
repo <- git_repo()
537538
tr <- target_repo(github_get = NA, role = target, ask = FALSE)

R/rename-files.R

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@
1212
#' This is a potentially dangerous operation, so you must be using Git in
1313
#' order to use this function.
1414
#'
15-
#' @param old,new Old and new file names (with or without extensions).
15+
#' @param old,new Old and new file names (with or without `.R` extensions).
1616
#' @export
1717
rename_files <- function(old, new) {
1818
check_uses_git()
19+
challenge_uncommitted_changes(
20+
msg = "
21+
There are uncommitted changes and we're about to bulk-rename files. It is \\
22+
highly recommended to get into a clean Git state before bulk-editing files",
23+
untracked = TRUE
24+
)
1925

20-
old <- path_ext_remove(old)
21-
new <- path_ext_remove(new)
26+
old <- sub("\\.R$", "", old)
27+
new <- sub("\\.R$", "", new)
2228

2329
# R/ ------------------------------------------------------------------------
2430
r_old_path <- proj_path("R", old, ext = "R")

0 commit comments

Comments
 (0)