Skip to content

Commit

Permalink
Merge branch 'main' into creative_commons
Browse files Browse the repository at this point in the history
  • Loading branch information
pachadotdev authored Nov 10, 2023
2 parents 54f248d + 52b45dc commit 4ffaa60
Show file tree
Hide file tree
Showing 39 changed files with 303 additions and 427 deletions.
2 changes: 1 addition & 1 deletion .github/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Before filing an issue, there are a few places to explore and pieces to put toge

Start by making a minimal **repr**oducible **ex**ample using the [reprex](https://reprex.tidyverse.org/) package.
If you haven't heard of or used reprex before, you're in for a treat!
Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty insane ROI for the five to ten minutes it'll take you to learn what it's all about).
Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty incredible ROI for the five to ten minutes it'll take you to learn what it's all about).
For additional reprex pointers, check out the [Get help!](https://www.tidyverse.org/help/) section of the tidyverse site.

## Where to ask?
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ jobs:
extra-packages: any::rcmdcheck
needs: check

- name: git config
if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release'
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "[email protected]"
- uses: r-lib/actions/check-r-package@v2
env:
_R_CALLS_INVALID_NUMERIC_VERSION_: true
with:
upload-snapshots: true
5 changes: 5 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ jobs:
extra-packages: any::covr
needs: coverage

- name: git config
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "[email protected]"
- name: Test coverage
run: |
covr::codecov(
Expand Down
6 changes: 4 additions & 2 deletions 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.0.9001
Version: 2.2.2.9000
Authors@R: c(
person("Hadley", "Wickham", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-4757-117X")),
Expand Down Expand Up @@ -47,14 +47,16 @@ Suggests:
covr,
knitr,
magick,
pkgload,
pkgload (>= 1.3.2.1),
rmarkdown,
roxygen2 (>= 7.1.2),
spelling (>= 1.2),
styler (>= 1.2.0),
testthat (>= 3.1.8)
Config/Needs/website: tidyverse/tidytemplate, xml2
Config/testthat/edition: 3
Config/testthat/parallel: TRUE
Config/testthat/start-first: github-actions, release
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,4 @@ importFrom(purrr,map)
importFrom(purrr,map_chr)
importFrom(purrr,map_int)
importFrom(purrr,map_lgl)
importFrom(utils,available.packages)
17 changes: 17 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# usethis (development version)

# usethis 2.2.2

* Implicit usage of `numeric_version()` via comparison now always provides
character input. This is in response to a request from CRAN to anticipate
future solutions to <https://bugs.r-project.org/show_bug.cgi?id=18548>.

# usethis 2.2.1

* Internal helper `cran_version()`, used in functions such as
`use_release_checklist()` and `use_news_md()`, is more resilient to situations
where no CRAN mirror has been set (#1857).

* Internal usage of `numeric_version()` now always provides character input,
rather than relying on implicit `as.character()` coercion. This is in response
to a request from CRAN to anticipate future solutions to
<https://bugs.r-project.org/show_bug.cgi?id=18548> (#1869).

# usethis 2.2.0

## New functions
Expand Down
1 change: 0 additions & 1 deletion R/cran.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use_cran_comments <- function(open = rlang::is_interactive()) {
check_is_package("use_cran_comments()")
use_template(
"cran-comments.md",
data = list(rversion = glue("{version$major}.{version$minor}")),
ignore = TRUE,
open = open
)
Expand Down
24 changes: 18 additions & 6 deletions R/documentation.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
#' Package-level documentation
#'
#' Adds a dummy `.R` file that will prompt roxygen to generate basic
#' Adds a dummy `.R` file that will cause roxygen2 to generate basic
#' package-level documentation. If your package is named "foo", this will make
#' help available to the user via `?foo` or `package?foo`. Once you call
#' `devtools::document()`, roxygen will flesh out the `.Rd` file using data from
#' the `DESCRIPTION`. That ensures you don't need to repeat the same information
#' in multiple places. This `.R` file is also a good place for roxygen
#' directives that apply to the whole package (vs. a specific function), such as
#' global namespace tags like `@importFrom`.
#' `devtools::document()`, roxygen2 will flesh out the `.Rd` file using data
#' from the `DESCRIPTION`. That ensures you don't need to repeat (and remember
#' to update!) the same information in multiple places. This `.R` file is also a
#' good place for roxygen directives that apply to the whole package (vs. a
#' specific function), such as global namespace tags like `@importFrom`.
#'
#' There is one tricky case: when a **package** named "foo" also has a
#' **function** named `foo()`. In this case, after running `use_package_doc()`,
#' there will be an `R CMD check` warning. The solution is to set the `@aliases`
#' for the package-level help topic by modifying the dummy `.R` file (e.g.,
#' `foo-package.R`) as shown below (but substitute the name of your package /
#' function for "foo"):
#'
#' ```
#' #' @keywords internal
#' #' @aliases foo-package
#' #' "_PACKAGE"
#' ```
#' @seealso The [documentation chapter](https://r-pkgs.org/man.html) of [R
#' Packages](https://r-pkgs.org)
#' @inheritParams use_template
Expand Down
2 changes: 1 addition & 1 deletion R/git.R
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ default_branch_sitrep <- function() {

#' Vaccinate your global gitignore file
#'
#' Adds `.DS_Store`, `.Rproj.user`, `.Rdata`, `.Rhistory`, and `.httr-oauth` to
#' Adds `.Rproj.user`, `.Rhistory`, `.Rdata`, `.httr-oauth`, `.DS_Store`, and `.quarto` to
#' your global (a.k.a. user-level) `.gitignore`. This is good practice as it
#' decreases the chance that you will accidentally leak credentials to GitHub.
#' `git_vaccinate()` also tries to detect and fix the situation where you have a
Expand Down
2 changes: 1 addition & 1 deletion R/r.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ compute_name <- function(name = NULL, ext = "R", error_call = caller_env()) {

if (path_ext(name) == "") {
name <- path_ext_set(name, ext)
} else if (path_ext(name) != "R") {
} else if (path_ext(name) != ext) {
cli::cli_abort(
"{.arg name} must have extension {.str {ext}}, not {.str {path_ext(name)}}.",
call = error_call
Expand Down
36 changes: 31 additions & 5 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ release_checklist <- function(version, on_cran) {
"Wait for CRAN...",
"",
todo("Accepted :tada:"),
todo("Add preemptive link to blog post in pkgdown news menu", type != "patch"),
todo("Finish & publish blog post", type != "patch"),
todo("Add link to blog post in pkgdown news menu", type != "patch"),
todo("`usethis::use_github_release()`"),
todo("`usethis::use_dev_version(push = TRUE)`"),
todo("`usethis::use_news_md()`", !has_news),
todo("Finish blog post", type != "patch"),
todo("Tweet", type != "patch")
)
}
Expand Down Expand Up @@ -403,8 +403,23 @@ get_release_news <- function(SHA = gert::git_info(repo = git_repo())$commit,
}
}

cran_version <- function(package = project_name(),
available = utils::available.packages()) {
cran_version <- function(package = project_name(), available = NULL) {

if (!curl::has_internet()) {
return(NULL)
}

if (is.null(available)) {
# Guard against CRAN mirror being unset
available <- tryCatch(
available.packages(repos = default_cran_mirror()),
error = function(e) NULL
)
if (is.null(available)) {
return(NULL)
}
}

idx <- available[, "Package"] == package
if (any(idx)) {
as.package_version(available[package, "Version"])
Expand Down Expand Up @@ -533,7 +548,18 @@ pkg_minimum_r_version <- function() {
deps <- proj_desc()$get_deps()
r_dep <- deps[deps$package == "R" & deps$type == "Depends", "version"]
if (length(r_dep) == 0) {
return(numeric_version(0))
return(numeric_version("0"))
}
numeric_version(gsub("[^0-9.]", "", r_dep))
}

# Borrowed from pak, but modified also retain user's non-cran repos:
# https://github.com/r-lib/pak/blob/168ab5d58fc244e5084c2800c87b8a574d66c3ba/R/default-cran-mirror.R
default_cran_mirror <- function() {
repos <- getOption("repos")
cran <- repos["CRAN"]
if (is.null(cran) || is.na(cran) || cran == "@CRAN@") {
repos["CRAN"] <- "https://cloud.r-project.org"
}
repos
}
Loading

0 comments on commit 4ffaa60

Please sign in to comment.