Skip to content

Commit

Permalink
GitLab URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Mar 7, 2024
1 parent 2c5d051 commit b7496fa
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 68 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.internals
Title: Internal Infrastructure for An R Universe of Package Releases
Description: Internal infrastructure for an R universe of package releases.
Version: 0.0.9
Version: 0.0.10
License: MIT + file LICENSE
URL: https://github.com/r-releases/r.releases.internals
BugReports: https://github.com/r-releases/r.releases.internals/issues
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# r.releases.internals 0.0.10

* Automatically merge GitLab URLs with non-"upcoming" releases.

# r.releases.internals 0.0.9

* Change the package name to `r.releases.internals`.
Expand Down
65 changes: 5 additions & 60 deletions R/assert_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ assert_package <- function(name, url) {

assert_package_lite <- function(name, url) {
if (!is_package_name(name)) {
return("Invalid package name.")
return("Invalid package name")
}
if (!is_character_scalar(url)) {
return("Invalid package URL.")
return("Invalid package URL")
}
name <- trimws(name)
url <- trimws(trim_trailing_slash(url))
Expand All @@ -45,7 +45,7 @@ assert_package_lite <- function(name, url) {
)
}
if (!identical(parsed_url[["scheme"]], "https")) {
return(paste("Scheme of URL", shQuote(url), "is not https."))
return(paste("Scheme of URL", shQuote(url), "is not https"))
}
}

Expand Down Expand Up @@ -78,13 +78,13 @@ assert_package_lints <- function(name, url) {
paste(
"URL",
shQuote(url),
"appears to be an owner, not a repository."
"appears to be an owner, not a repository"
)
)
}
owner <- tolower(splits[nzchar(splits)][1L])
if (identical(owner, "cran")) {
return(paste("URL", shQuote(url), "appears to use a CRAN mirror."))
return(paste("URL", shQuote(url), "appears to use a CRAN mirror"))
}
}

Expand All @@ -101,58 +101,3 @@ assert_url_exists <- function(url) {
)
}
}

#' @title Check for a release.
#' @export
#' @keywords internal
#' @description Check for a release.
#' @return A character string if there is a problem with the package entry,
#' otherwise `NULL` if there are no issues.
#' @inheritParams assert_package
assert_release_exists <- function(url) {
if (nanonext::parse_url(url)[["host"]] == "gitlab.com") {
return(
paste0(
"Trying to find a release at ",
shQuote(url),
". Unfortunately, GitLab releases are hard to detect automatically."
)
)
}
response <- nanonext::ncurl(
file.path(url, "releases", "latest"),
convert = FALSE
)
status <- response[["status"]]
if (status != 302L) {
return(
paste(
"Checking releases at",
shQuote(url),
"returned HTTP error",
nanonext::status_code(status)
)
)
}
found <- identical(
dirname(as.character(response$headers$Location)),
file.path(url, "releases", "tag")
)
if (!found) {
return(
paste0(
"No release found at URL ",
shQuote(url),
". To bypass manual review and have a smoother package ",
"registration experience, you could close this pull request, ",
"create a release for your package, ",
"and then try submitting another pull request. ",
"Please see ",
shQuote(
"https://github.com/r-lib/gh/releases/tag/v1.4.0"
),
" for an example of a release."
)
)
}
}
2 changes: 1 addition & 1 deletion man/assert_release_exists.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 16 additions & 6 deletions tests/test-assert_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,21 @@ stopifnot(

stopifnot(
grepl(
"No release found at URL",
"No full release found at URL",
r.releases.internals::assert_package(
name = "dllreprex",
url = "https://github.com/wlandau/dllreprex"
name = "test.no.release",
url = "https://github.com/wlandau/test.no.release"
),
fixed = TRUE
)
)

stopifnot(
grepl(
"GitLab releases are hard to detect automatically",
r.releases.internals::assert_release_exists(
url = "https://gitlab.com/owner/repo"
"No full release found at URL",
r.releases.internals::assert_package(
name = "test.no.release",
url = "https://gitlab.com/wlandau/test.no.release"
),
fixed = TRUE
)
Expand All @@ -192,6 +193,15 @@ stopifnot(
)
)

stopifnot(
is.null(
r.releases.internals::assert_package(
name = "test",
url = "https://gitlab.com/wlandau/test"
)
)
)

stopifnot(
is.null(
r.releases.internals::assert_cran_url(
Expand Down

0 comments on commit b7496fa

Please sign in to comment.