-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from r-releases/gitlab-and-cran
GitLab releases and `"branch": "release"` exceptions
- Loading branch information
Showing
12 changed files
with
244 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#' @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) { | ||
host <- url_parse(url)[["host"]] | ||
if (host == "github.com") { | ||
assert_release_github(url) | ||
} else if (host == "gitlab.com") { | ||
assert_release_gitlab(url) | ||
} | ||
} | ||
|
||
assert_release_github <- function(url) { | ||
parsed_url <- url_parse(url) | ||
releases <- try( | ||
gh::gh( | ||
endpoint = "/repos/:owner/:repo/releases", | ||
owner = basename(dirname(parsed_url[["path"]])), | ||
repo = basename(parsed_url[["path"]]) | ||
), | ||
silent = TRUE | ||
) | ||
if (inherits(releases, "try-error")) { | ||
return(try_message(releases)) | ||
} | ||
releases <- Filter( | ||
f = function(release) { | ||
!isTRUE(release$prerelease) | ||
}, | ||
x = releases | ||
) | ||
if (!length(releases)) { | ||
return(paste("No full release found at URL", shQuote(url))) | ||
} | ||
} | ||
|
||
assert_release_gitlab <- function(url) { | ||
parsed_url <- url_parse(url) | ||
owner <- basename(dirname(parsed_url[["path"]])) | ||
repo <- basename(parsed_url[["path"]]) | ||
endpoint <- sprintf( | ||
"https://gitlab.com/api/v4/projects/%s%s%s/releases", | ||
owner, | ||
"%2F", | ||
repo | ||
) | ||
releases <- try( | ||
suppressWarnings( | ||
jsonlite::stream_in( | ||
con = gzcon(url(endpoint)), | ||
simplifyVector = TRUE, | ||
simplifyDataFrame = TRUE | ||
) | ||
), | ||
silent = TRUE | ||
) | ||
if (inherits(releases, "try-error")) { | ||
return(try_message(releases)) | ||
} | ||
if (!nrow(releases) || !any(!releases$upcoming_release)) { | ||
return(paste("No full release found at URL", shQuote(url))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.