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
}

0 commit comments

Comments
 (0)