Skip to content

Commit

Permalink
Merge pull request #5 from r-releases/urlcheck
Browse files Browse the repository at this point in the history
Actually check the live URL
  • Loading branch information
wlandau authored Mar 2, 2024
2 parents 00e3c47 + 898657d commit f2816cc
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: r.releases.utils
Title: Utilities for An R Universe of Package Releases
Description: Utilities for an R universe of package releases.
Version: 0.0.5
Version: 0.0.6
License: MIT + file LICENSE
URL:
https://r-releases.github.io/r.releases.utils/,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export(try_message)
importFrom(gh,gh)
importFrom(jsonlite,parse_json)
importFrom(jsonlite,read_json)
importFrom(nanonext,ncurl)
importFrom(nanonext,parse_url)
importFrom(nanonext,status_code)
importFrom(pkgsearch,cran_package)
importFrom(vctrs,vec_rbind)
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# r.releases.utils 0.0.6

* Check URL exists as part of package verification.

# r.releases.utils 0.0.5

* Write pretty JSON to `packages.json` (@llrs, https://github.com/r-releases/help/issues/4).
Expand Down
11 changes: 11 additions & 0 deletions R/assert_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ assert_package <- function(name, url) {
if (identical(owner, "cran")) {
return(paste("URL", shQuote(url), "appears to use a CRAN mirror."))
}
status <- nanonext::ncurl(url)[["status"]]
if (status != 200L) {
return(
paste(
"URL",
shQuote(url),
"returned HTTP error",
nanonext::status_code(status)
)
)
}
assert_cran_url(name = name, url = url)
}

Expand Down
2 changes: 1 addition & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @family help
#' @importFrom gh gh
#' @importFrom jsonlite parse_json read_json
#' @importFrom nanonext parse_url
#' @importFrom nanonext ncurl parse_url status_code
#' @importFrom pkgsearch cran_package
#' @importFrom vctrs vec_rbind
NULL
11 changes: 11 additions & 0 deletions tests/test-assert_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ stopifnot(
)
)

stopifnot(
grepl(
"returned HTTP error",
r.releases.utils::assert_package(
name = "afantasticallylongandimpossiblepackage",
url = "https://github.com/r-lib/afantasticallylongandimpossiblepackage"
),
fixed = TRUE
)
)

stopifnot(
is.null(
r.releases.utils::assert_package(
Expand Down

0 comments on commit f2816cc

Please sign in to comment.