Skip to content

Commit af2f01b

Browse files
committed
Merged upstream/main into olivroy-challenge-uncommited-tweaks
2 parents b9794fa + 46e3fef commit af2f01b

Some content is hidden

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

51 files changed

+652
-463
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ Config/testthat/start-first: github-actions, release
6060
Encoding: UTF-8
6161
Language: en-US
6262
Roxygen: list(markdown = TRUE)
63-
RoxygenNote: 7.3.1
63+
RoxygenNote: 7.3.2

NAMESPACE

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export(browse_cran)
1111
export(browse_github)
1212
export(browse_github_actions)
1313
export(browse_github_issues)
14-
export(browse_github_pat)
1514
export(browse_github_pulls)
16-
export(browse_github_token)
1715
export(browse_package)
1816
export(browse_project)
1917
export(browse_travis)
@@ -45,7 +43,6 @@ export(git_protocol)
4543
export(git_remotes)
4644
export(git_sitrep)
4745
export(git_vaccinate)
48-
export(github_token)
4946
export(issue_close_community)
5047
export(issue_reprex_needed)
5148
export(local_project)
@@ -56,10 +53,8 @@ export(pr_init)
5653
export(pr_merge_main)
5754
export(pr_pause)
5855
export(pr_pull)
59-
export(pr_pull_upstream)
6056
export(pr_push)
6157
export(pr_resume)
62-
export(pr_sync)
6358
export(pr_view)
6459
export(proj_activate)
6560
export(proj_get)

NEWS.md

Lines changed: 214 additions & 183 deletions
Large diffs are not rendered by default.

R/badge.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use_badge <- function(badge_name, href, src) {
4545
if (is.null(path)) {
4646
ui_bullets(c(
4747
"!" = "Can't find a README for the current project.",
48-
"i" = "See {.help usethis::use_readme_rmd} for help creating this file.",
48+
"i" = "See {.fun usethis::use_readme_rmd} for help creating this file.",
4949
"i" = "Badge link will only be printed to screen."
5050
))
5151
path <- "README"
@@ -60,7 +60,7 @@ use_badge <- function(badge_name, href, src) {
6060

6161
if (changed && path_ext(path) == "Rmd") {
6262
ui_bullets(c(
63-
"_" = "Re-knit {.path {pth(path)}} with {.fun devtools::build_readme}."
63+
"_" = "Re-knit {.path {pth(path)}} with {.run devtools::build_readme()}."
6464
))
6565
}
6666
invisible(changed)

R/coverage.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ use_covr_ignore <- function(files) {
4444
}
4545

4646
use_codecov_badge <- function(repo_spec) {
47-
default_branch <- git_default_branch()
48-
url <- glue("https://app.codecov.io/gh/{repo_spec}?branch={default_branch}")
49-
img <- glue("https://codecov.io/gh/{repo_spec}/branch/{default_branch}/graph/badge.svg")
47+
url <- glue("https://codecov.io/gh/{repo_spec}")
48+
img <- glue("https://codecov.io/gh/{repo_spec}/graph/badge.svg")
5049
use_badge("Codecov test coverage", url, img)
5150
}
5251

R/create.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#' any existing files are changed.
1111
#'
1212
#' @inheritParams use_description
13+
#' @param fields A named list of fields to add to `DESCRIPTION`, potentially
14+
#' overriding default values. See [use_description()] for how you can set
15+
#' personalized defaults using package options.
1316
#' @param path A path. If it exists, it is used. If it does not exist, it is
1417
#' created, provided that the parent path exists.
1518
#' @param roxygen Do you plan to use roxygen2 to document your package?

R/description.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#' usethis consults the following sources, in this order, to set `DESCRIPTION`
1515
#' fields:
16-
#' * `fields` argument of [create_package()] or [use_description()]
16+
#' * `fields` argument of [create_package()] or `use_description()`
1717
#' * `getOption("usethis.description")`
1818
#' * Defaults built into usethis
1919
#'
@@ -44,8 +44,9 @@
4444
#' supported.
4545
#'
4646
#' @param fields A named list of fields to add to `DESCRIPTION`, potentially
47-
#' overriding default values. See [use_description()] for how you can set
48-
#' personalized defaults using package options.
47+
#' overriding default values. Default values are taken from the
48+
#' `"usethis.description"` option or the usethis package (in that order), and
49+
#' can be viewed with `use_description_defaults()`.
4950
#' @param check_name Whether to check if the name is valid for CRAN and throw an
5051
#' error if not.
5152
#' @param roxygen If `TRUE`, sets `RoxygenNote` to current roxygen2 version

R/edit.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ choose_template <- function() {
8787
#' * `edit_pkgdown_config` opens the pkgdown YAML configuration file for the
8888
#' current Project.
8989
#' * `edit_rstudio_snippets()` opens RStudio's snippet config for the given type.
90-
#' * `edit_rstudio_prefs()` opens RStudio's preference file.
90+
#' * `edit_rstudio_prefs()` opens [RStudio's preference file][use_rstudio_preferences()].
9191
#'
9292
#' The `edit_r_*()` functions consult R's notion of user's home directory.
9393
#' The `edit_git_*()` functions (and \pkg{usethis} in general) inherit home
@@ -144,7 +144,7 @@ edit_r_makevars <- function(scope = c("user", "project")) {
144144
#' @param type Snippet type (case insensitive text).
145145
edit_rstudio_snippets <- function(type = c(
146146
"r", "markdown", "c_cpp", "css",
147-
"html", "java", "javascript", "python", "sql", "stan", "tex"
147+
"html", "java", "javascript", "python", "sql", "stan", "tex", "yaml"
148148
)) {
149149

150150
type <- tolower(type)

R/git.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ use_git <- function(message = "Initial commit") {
1515
if (needs_init) {
1616
ui_bullets(c("v" = "Initialising Git repo."))
1717
git_init()
18+
# hacky but helps prevent a pop-up in Positron, where early attempts to
19+
# interact with a newly created repo lead to:
20+
# Git: There are no available repositories
21+
# https://github.com/r-lib/usethis/pull/2011#issue-2380380721
22+
if (is_positron()) {
23+
Sys.sleep(1)
24+
}
1825
}
1926

2027
use_git_ignore(git_ignore_lines)
2128
if (git_uncommitted(untracked = TRUE)) {
2229
git_ask_commit(message, untracked = TRUE)
2330
}
2431

25-
if (needs_init) {
32+
if (needs_init && !is_positron()) {
2633
restart_rstudio("A restart of RStudio is required to activate the Git pane.")
2734
}
2835

R/github.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ use_github_links <- function(auth_token = deprecated(),
239239
invisible()
240240
}
241241

242-
has_github_links <- function() {
243-
github_url <- github_url_from_git_remotes()
242+
has_github_links <- function(target_repo = NULL) {
243+
url <- if (is.null(target_repo)) NULL else target_repo$url
244+
github_url <- github_url_from_git_remotes(url)
244245
if (is.null(github_url)) {
245246
return(FALSE)
246247
}
@@ -269,21 +270,23 @@ check_no_origin <- function() {
269270
}
270271

271272
check_no_github_repo <- function(owner, repo, host) {
273+
spec <- glue("{owner}/{repo}")
272274
repo_found <- tryCatch(
273275
{
274-
repo_info <- gh::gh(
275-
"/repos/{owner}/{repo}",
276-
owner = owner, repo = repo,
277-
.api_url = host
278-
)
279-
TRUE
276+
repo_info <- gh::gh("/repos/{spec}", spec = spec, .api_url = host)
277+
# when does repo_info$full_name != the spec we sent?
278+
# this happens if you reuse the original name of a repo that has since
279+
# been renamed
280+
# there's no 404, because of the automatic redirect, but you CAN create
281+
# a new repo with this name
282+
# https://github.com/r-lib/usethis/issues/1893
283+
repo_info$full_name == spec
280284
},
281285
"http_error_404" = function(err) FALSE
282286
)
283287
if (!repo_found) {
284288
return(invisible())
285289
}
286-
spec <- glue("{owner}/{repo}")
287290
empirical_host <- parse_github_remotes(repo_info$html_url)$host
288291
ui_abort("Repo {.val {spec}} already exists on {.val {empirical_host}}.")
289292
}

R/github_token.R

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,23 @@ create_github_token <- function(scopes = c("repo", "user", "gist", "workflow"),
6767
withr::defer(view_url(url))
6868

6969
hint <- code_hint_with_host("gitcreds::gitcreds_set", host)
70-
ui_bullets(c(
71-
"_" = "Call {.code {hint}} to register this token in the local Git
72-
credential store.",
70+
message <- c(
71+
"_" = "Call {.run {hint}} to register this token in the local Git
72+
credential store."
73+
)
74+
if (is_linux()) {
75+
message <- c(
76+
message,
77+
"!" = "On Linux, it can be tricky to store credentials persistently.",
78+
"i" = "Read more in the {.href ['Managing Git(Hub) Credentials' article](https://usethis.r-lib.org/articles/articles/git-credentials.html)}."
79+
)
80+
}
81+
message <- c(
82+
message,
7383
"i" = "It is also a great idea to store this token in any
7484
password-management software that you use."
75-
))
85+
)
86+
ui_bullets(message)
7687
invisible()
7788
}
7889

@@ -130,14 +141,14 @@ pat_sitrep <- function(host = "https://github.com",
130141

131142
if (!have_pat) {
132143
kv_line("Personal access token for {.val {host}}", NULL)
133-
hint <- code_hint_with_host("create_github_token", host, "host")
144+
hint <- code_hint_with_host("usethis::create_github_token", host, "host")
134145
ui_bullets(c(
135-
"_" = "To create a personal access token, call {.code {hint}}."
146+
"_" = "To create a personal access token, call {.run {hint}}."
136147
))
137148
hint <- code_hint_with_host("gitcreds::gitcreds_set", host)
138149
url <- "https://usethis.r-lib.org/articles/articles/git-credentials.html"
139150
ui_bullets(c(
140-
"_" = "To store a token for current and future use, call {.code {hint}}.",
151+
"_" = "To store a token for current and future use, call {.run {hint}}.",
141152
"i" = "Read more in the {.href [Managing Git(Hub) Credentials]({url})} article."
142153
))
143154
return(invisible(FALSE))
@@ -166,7 +177,7 @@ pat_sitrep <- function(host = "https://github.com",
166177
}
167178
message <- c(
168179
message,
169-
"i" = maybe_who$error
180+
"i" = maybe_who$error$message
170181
)
171182
ui_bullets(message)
172183
return(invisible(FALSE))

R/import-standalone-obj-type.R

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
# Standalone file: do not edit by hand
2-
# Source: <https://github.com/r-lib/rlang/blob/main/R/standalone-obj-type.R>
2+
# Source: https://github.com/r-lib/rlang/blob/HEAD/R/standalone-obj-type.R
3+
# Generated by: usethis::use_standalone("r-lib/rlang", "obj-type")
34
# ----------------------------------------------------------------------
45
#
56
# ---
67
# repo: r-lib/rlang
78
# file: standalone-obj-type.R
8-
# last-updated: 2022-10-04
9+
# last-updated: 2024-02-14
910
# license: https://unlicense.org
1011
# imports: rlang (>= 1.1.0)
1112
# ---
1213
#
1314
# ## Changelog
1415
#
16+
# 2024-02-14:
17+
# - `obj_type_friendly()` now works for S7 objects.
18+
#
19+
# 2023-05-01:
20+
# - `obj_type_friendly()` now only displays the first class of S3 objects.
21+
#
22+
# 2023-03-30:
23+
# - `stop_input_type()` now handles `I()` input literally in `arg`.
24+
#
1525
# 2022-10-04:
1626
# - `obj_type_friendly(value = TRUE)` now shows numeric scalars
1727
# literally.
@@ -65,7 +75,7 @@ obj_type_friendly <- function(x, value = TRUE) {
6575
if (inherits(x, "quosure")) {
6676
type <- "quosure"
6777
} else {
68-
type <- paste(class(x), collapse = "/")
78+
type <- class(x)[[1L]]
6979
}
7080
return(sprintf("a <%s> object", type))
7181
}
@@ -261,19 +271,19 @@ vec_type_friendly <- function(x, length = FALSE) {
261271
#' Return OO type
262272
#' @param x Any R object.
263273
#' @return One of `"bare"` (for non-OO objects), `"S3"`, `"S4"`,
264-
#' `"R6"`, or `"R7"`.
274+
#' `"R6"`, or `"S7"`.
265275
#' @noRd
266276
obj_type_oo <- function(x) {
267277
if (!is.object(x)) {
268278
return("bare")
269279
}
270280

271-
class <- inherits(x, c("R6", "R7_object"), which = TRUE)
281+
class <- inherits(x, c("R6", "S7_object"), which = TRUE)
272282

273283
if (class[[1]]) {
274284
"R6"
275285
} else if (class[[2]]) {
276-
"R7"
286+
"S7"
277287
} else if (isS4(x)) {
278288
"S4"
279289
} else {
@@ -315,10 +325,15 @@ stop_input_type <- function(x,
315325
if (length(what)) {
316326
what <- oxford_comma(what)
317327
}
328+
if (inherits(arg, "AsIs")) {
329+
format_arg <- identity
330+
} else {
331+
format_arg <- cli$format_arg
332+
}
318333

319334
message <- sprintf(
320335
"%s must be %s, not %s.",
321-
cli$format_arg(arg),
336+
format_arg(arg),
322337
what,
323338
obj_type_friendly(x, value = show_value)
324339
)

R/import-standalone-types-check.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Standalone file: do not edit by hand
2-
# Source: <https://github.com/r-lib/rlang/blob/main/R/standalone-types-check.R>
2+
# Source: https://github.com/r-lib/rlang/blob/HEAD/R/standalone-types-check.R
3+
# Generated by: usethis::use_standalone("r-lib/rlang", "types-check")
34
# ----------------------------------------------------------------------
45
#
56
# ---

R/news.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,20 @@ use_news_heading <- function(version) {
4040
}
4141

4242
news <- read_utf8(news_path)
43-
title <- glue("# {project_name()} {version}")
43+
idx <- match(TRUE, grepl("[^[:space:]]", news))
44+
45+
if (is.na(idx)) {
46+
return(news)
47+
}
4448

45-
if (title == news[[1]]) {
49+
title <- glue("# {project_name()} {version}")
50+
if (title == news[[idx]]) {
4651
return(invisible())
4752
}
4853

4954
development_title <- glue("# {project_name()} (development version)")
50-
if (development_title == news[[1]]) {
51-
news[[1]] <- title
55+
if (development_title == news[[idx]]) {
56+
news[[idx]] <- title
5257

5358
ui_bullets(c("v" = "Replacing development heading in {.path NEWS.md}."))
5459
return(write_utf8(news_path, news))

R/package.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
#' "Suggests", "Enhances", or "LinkingTo" (or unique abbreviation). Matching
2424
#' is case insensitive.
2525
#' @param min_version Optionally, supply a minimum version for the package. Set
26-
#' to `TRUE` to use the currently installed version.
26+
#' to `TRUE` to use the currently installed version or use a version string
27+
#' suitable for [numeric_version()], such as "2.5.0".
2728
#' @param remote By default, an `OWNER/REPO` GitHub remote is inserted.
2829
#' Optionally, you can supply a character string to specify the remote, e.g.
2930
#' `"gitlab::jimhester/covr"`, using any syntax supported by the [remotes

R/positron.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
is_positron <- function() {
2+
Sys.getenv("POSITRON") == "1"
3+
}

R/proj.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ proj_set <- function(path = ".", force = FALSE) {
9090
if (is.null(new_project)) {
9191
ui_abort(c(
9292
"Path {.path {pth(path)}} does not appear to be inside a project or package.",
93-
"Read more in the help for {.help usethis::proj_get}."
93+
"Read more in the help for {.fun usethis::proj_get}."
9494
))
9595
}
9696
proj_set(path = new_project, force = TRUE)
@@ -227,7 +227,7 @@ check_is_project <- function() {
227227
if (!possibly_in_proj()) {
228228
ui_abort(c(
229229
"We do not appear to be inside a valid project or package.",
230-
"Read more in the help for {.help usethis::proj_get}."
230+
"Read more in the help for {.fun usethis::proj_get}."
231231
))
232232
}
233233
}

0 commit comments

Comments
 (0)