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 2e59179 + 0e20668 commit 9841741
Show file tree
Hide file tree
Showing 50 changed files with 799 additions and 339 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
pull_request:
branches: [main, master]

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

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

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

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
issue_comment:
types: [created]

name: Commands
name: pr-commands.yaml

permissions: read-all

Expand All @@ -15,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -52,6 +54,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: usethis
Title: Automate Package and Project Setup
Version: 2.2.3.9000
Version: 3.0.0.9000
Authors@R: c(
person("Hadley", "Wickham", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-4757-117X")),
Expand Down
71 changes: 41 additions & 30 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
# usethis (development version)

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

* `use_cpp11()` makes it easier to update `NAMESPACE` (@pachadotdev, #1921).

* `pr_merge_main()` now offers the choice to not open the files with merge conflicts (@olivroy, #1720).

* `edit_rstudio_snippets()` now accepts yaml snippets (@olivroy, #1941).

* `use_standalone()` inserts an improved header that includes the code needed to
update the standalone file (@krlmlr, #1903).

* `use_release_issue()` and `use_upkeep()` behave better when the user has a
fork. The user is asked just once to choose between `origin` and `upstream` as
the target repo (#2023).

* The README templates now recommend [pak](https://pak.r-lib.org) instead of
devtools for package installation (@olivroy, #1723).

* `use_github()` now knows that you can reuse the name of an earlier repo that
has since been renamed (@ateucher, #1893).

* `use_git()` no longer asks if you want to restart RStudio when using Positron.

* `use_test()` and `use_r()` now work when you are in `tests/testthat/_snaps/{foo}.md` (@olivroy, #1988).

* The URLs baked into the badge generated by `use_coverage(type = "codecov")`
no longer specify a branch (#2008).
## Transition to cli package for UI

* The `ui_*()` functions have been marked as
[superseded](https://lifecycle.r-lib.org/articles/stages.html#superseded).
Expand All @@ -37,13 +13,9 @@
superior option.
There is a cli vignette about how to make this transition:
`vignette("usethis-ui", package = "cli")`.

usethis no longer uses the `ui_*()` functions internally, in favor of new
cli-based helpers that are not exported.

* `usethis::use_version()` now tolerates empty / blank lines preceding the
first section title in the package NEWS file. (#1976)

## Deprecated function and argument removal

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

## Other changes

* `use_zip()` and `use_course()` are equipped to handle a ZIP where the parent
folder is implicit (@burnsal, #1961).

* `use_test_helper()` is a new function to create a test helper file
(@olivroy, #1822).

* `use_cpp11()` makes it easier to update `NAMESPACE` (@pachadotdev, #1921).

* `pr_merge_main()` now offers the choice to not open the files with merge
conflicts (@olivroy, #1720).

* `edit_rstudio_snippets()` now accepts yaml snippets (@olivroy, #1941).

* `use_standalone()` inserts an improved header that includes the code needed to
update the standalone file (@krlmlr, #1903).

* `use_release_issue()` and `use_upkeep_issue()` behave better when the user has
a fork. The user is asked just once to choose between `origin` and `upstream`
as the target repo (#2023).

* The README templates now recommend [pak](https://pak.r-lib.org) instead of
devtools for package installation (@olivroy, #1723).

* `use_github()` now knows that you can reuse the name of an earlier repo that
has since been renamed (@ateucher, #1893).

* `use_git()` no longer asks if you want to restart RStudio when using Positron.

* `use_test()` and `use_r()` now work when you are in
`tests/testthat/_snaps/{foo}.md` (@olivroy, #1988).

* The URLs baked into the badge generated by `use_coverage(type = "codecov")`
are updated and no longer specify a branch(#2008).

* `usethis::use_version()` now tolerates empty lines preceding the
first section title in the package NEWS file. (#1976)

# usethis 2.2.3

* Patch release with changes to `.Rd` files requested by CRAN.
Expand Down
10 changes: 0 additions & 10 deletions R/badge.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,6 @@ use_posit_cloud_badge <- function(url) {
invisible(TRUE)
}

#' @rdname badges
#' @export
use_rscloud_badge <- function(url) {
lifecycle::deprecate_warn(
"2.2.0", "use_rscloud_badge()",
"use_posit_cloud_badge()"
)
use_posit_cloud_badge(url)
}

has_badge <- function(href) {
readme_path <- proj_path("README.md")
if (!file_exists(readme_path)) {
Expand Down
3 changes: 0 additions & 3 deletions R/browse.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#' DESCRIPTION file is sought first in the local package library and then
#' on CRAN.
#' * Fixed templates:
#' - Travis CI: `https://travis-ci.{EXT}/{OWNER}/{PACKAGE}`
#' - Circle CI: `https://circleci.com/gh/{OWNER}/{PACKAGE}`
#' - CRAN landing page: `https://cran.r-project.org/package={PACKAGE}`
#' - GitHub mirror of a CRAN package: `https://github.com/cran/{PACKAGE}`
Expand All @@ -29,8 +28,6 @@
#' issue.
#' * `browse_github_pulls()`: Visits the GitHub Pull Request index or one
#' specific pull request.
#' * `browse_travis()`: Visits the project's page on
#' [Travis CI](https://www.travis-ci.com/).
#' * `browse_circleci()`: Visits the project's page on
#' [Circle CI](https://circleci.com).
#' * `browse_cran()`: Visits the package on CRAN, via the canonical URL.
Expand Down
48 changes: 25 additions & 23 deletions R/course.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#' @param url Link to a ZIP file containing the materials. To reduce the chance
#' of typos in live settings, these shorter forms are accepted:
#'
#' * 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".
#' 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,
#' and Google Drive.
#' * 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".
#' 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,
#' and Google Drive.
#' @param destdir Destination for the new folder. Defaults to the location
#' stored in the global option `usethis.destdir`, if defined, or to the user's
#' Desktop or similarly conspicuous place otherwise.
Expand Down Expand Up @@ -360,15 +360,15 @@ tidy_unzip <- function(zipfile, cleanup = FALSE) {
## DropBox ZIP files often include lots of hidden R, RStudio, and Git files
filenames <- filenames[keep_lgl(filenames)]

td <- top_directory(filenames)
loose_parts <- is.na(td)

if (loose_parts) {
parents <- path_before_slash(filenames)
unique_parents <- unique(parents)
if (length(unique_parents) == 1 && unique_parents != "") {
target <- path(base_path, unique_parents)
utils::unzip(zipfile, files = filenames, exdir = base_path)
} else {
# there is no parent; archive contains loose parts
target <- path_ext_remove(zipfile)
utils::unzip(zipfile, files = filenames, exdir = target)
} else {
target <- path(base_path, td)
utils::unzip(zipfile, files = filenames, exdir = base_path)
}
ui_bullets(c(
"v" = "Unpacking ZIP file into {.path {pth(target, base_path)}}
Expand Down Expand Up @@ -398,7 +398,7 @@ tidy_unzip <- function(zipfile, cleanup = FALSE) {
}
}

invisible(target)
invisible(unclass(target))
}

#' @rdname use_course_details
Expand Down Expand Up @@ -525,15 +525,17 @@ keep_lgl <- function(file,
!grepl(ignores, file, perl = TRUE)
}

top_directory <- function(filenames) {
in_top <- path_dir(filenames) == "."
unique_top <- unique(filenames[in_top])
is_directory <- grepl("/$", unique_top)
if (length(unique_top) > 1 || !is_directory) {
NA_character_
} else {
unique_top
path_before_slash <- function(filepath) {
f <- function(x) {
parts <- strsplit(x, "/", fixed = TRUE)[[1]]
if (length(parts) > 1 || grepl("/", x)) {
parts[1]
} else {
""
}
}
purrr::map_chr(filepath, f)

}

content_type <- function(h) {
Expand Down
2 changes: 1 addition & 1 deletion R/coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use_covr_ignore <- function(files) {
}

use_codecov_badge <- function(repo_spec) {
url <- glue("https://codecov.io/gh/{repo_spec}")
url <- glue("https://app.codecov.io/gh/{repo_spec}")
img <- glue("https://codecov.io/gh/{repo_spec}/graph/badge.svg")
use_badge("Codecov test coverage", url, img)
}
Expand Down
2 changes: 1 addition & 1 deletion R/git.R
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ git_sitrep <- function(tool = c("git", "github"),
if (!vaccinated) {
ui_bullets(c("i" = "See {.fun usethis::git_vaccinate} to learn more."))
}
kv_line("Default Git protocol", git_protocol())
kv_line("Default Git protocol", ui_silence(git_protocol()))
kv_line("Default initial branch name", init_default_branch)
}

Expand Down
10 changes: 8 additions & 2 deletions R/github-actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ use_github_action <- function(name = NULL,
ui_bullets(c("_" = "Learn more at {.url {readme}}."))
}

badge <- badge %||% is_check_action(url)
if (badge) {
if (badge %||% is_check_action(url)) {
use_github_actions_badge(path_file(save_as))
}
if (badge %||% is_coverage_action(url)) {
use_codecov_badge(target_repo_spec())
}

invisible(new)
}
Expand Down Expand Up @@ -167,6 +169,10 @@ is_check_action <- function(url) {
grepl("^check-", path_file(url))
}

is_coverage_action <- function(url) {
grepl("test-coverage", path_file(url))
}

#' Generates a GitHub Actions badge
#'
#' Generates a GitHub Actions badge and that's all. This exists primarily for
Expand Down
2 changes: 1 addition & 1 deletion R/github-labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ tidy_label_descriptions <- function() {
"good first issue :heart:" = "good issue for first-time contributors",
"help wanted :heart:" = "we'd love your help!",
"breaking change :skull_and_crossbones:" = "API change likely to affect existing code",
"tidy-dev-day :nerd_face:" = "Tidyverse Developer Day rstd.io/tidy-dev-day"
"tidy-dev-day :nerd_face:" = "Tidyverse Developer Day"
)
}

Expand Down
4 changes: 2 additions & 2 deletions R/issue.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#' by the tidyverse team.
#'
#' * `issue_close_community()` closes an issue, because it's not a bug report or
#' feature request, and points the author towards RStudio Community as a
#' better place to discuss usage (<https://community.rstudio.com>).
#' feature request, and points the author towards Posit Community as a
#' better place to discuss usage (<https://forum.posit.co>).
#'
#' * `issue_reprex_needed()` labels the issue with the "reprex" label and
#' gives the author some advice about what is needed.
Expand Down
2 changes: 1 addition & 1 deletion R/pipe.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Use magrittr's pipe in your package
#'
#' Does setup necessary to use magrittr's pipe operator, `%>%` in your package.
#' This function requires the use roxygen.
#' This function requires the use of \pkg{roxygen2}.
#' * Adds magrittr to "Imports" in `DESCRIPTION`.
#' * Imports the pipe operator specifically, which is necessary for internal
#' use.
Expand Down
1 change: 1 addition & 0 deletions R/pr.R
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ pr_forget <- function() pr_clean(mode = "forget")
pr_clean <- function(number = NULL,
target = c("source", "primary"),
mode = c("finish", "forget")) {
withr::defer(rstudio_git_tickle())
mode <- match.arg(mode)
repo <- git_repo()
tr <- target_repo(github_get = NA, role = target, ask = FALSE)
Expand Down
12 changes: 9 additions & 3 deletions R/rename-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
#' This is a potentially dangerous operation, so you must be using Git in
#' order to use this function.
#'
#' @param old,new Old and new file names (with or without extensions).
#' @param old,new Old and new file names (with or without `.R` extensions).
#' @export
rename_files <- function(old, new) {
check_uses_git()
challenge_uncommitted_changes(
msg = "
There are uncommitted changes and we're about to bulk-rename files. It is \\
highly recommended to get into a clean Git state before bulk-editing files",
untracked = TRUE
)

old <- path_ext_remove(old)
new <- path_ext_remove(new)
old <- sub("\\.R$", "", old)
new <- sub("\\.R$", "", new)

# R/ ------------------------------------------------------------------------
r_old_path <- proj_path("R", old, ext = "R")
Expand Down
Loading

0 comments on commit 9841741

Please sign in to comment.