Skip to content

Commit

Permalink
Allowing some mustWork passthroughs.
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 committed Aug 31, 2018
1 parent dc930e5 commit 5993dfc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
10 changes: 9 additions & 1 deletion R/binary_release_table.R
Expand Up @@ -98,6 +98,9 @@ binary_release_table = function(
#' @rdname binary_release_table
#' @export
#' @examples
#' @param mustWork Does the command need to work? If fails,
#' will error. But \code{FALSE} will try to pass
#' appropriate missing data value
#' repo = "stnava/ANTsR"
#' binary_table_no_tags(repo)
#' binary_table_no_tags("muschellij2/ANTsR")
Expand All @@ -107,6 +110,7 @@ binary_table_no_tags = function(
pat = NULL,
force = FALSE,
verbose = TRUE,
mustWork = TRUE,
...){

info = parse_one_remote(repo)
Expand All @@ -121,7 +125,11 @@ binary_table_no_tags = function(
url = paste0("https://api.github.com/repos/", repo, "/releases")

get_df = function(res) {

if (!mustWork) {
if (httr::status_code(res) > 400) {
return(NA)
}
}
httr::stop_for_status(res)
if (verbose) {
httr::message_for_status(res)
Expand Down
15 changes: 14 additions & 1 deletion R/tag_table.R
Expand Up @@ -4,6 +4,9 @@
#' @param repo Remote repository name
#' @param pat GitHub Personal Authentication Token (PAT)
#' @param ... additional arguments to \code{\link[httr]{GET}}
#' @param mustWork Does the command need to work? If fails,
#' will error. But \code{FALSE} will try to pass
#' appropriate missing data value
#' @return \code{data.frame} of tags
#' @export
#'
Expand All @@ -14,7 +17,10 @@
#' tag_table("cran/psych@084bdd0ae2630cf31c26d97a6e13e59d3f0f66e6")
#' @importFrom httr GET content stop_for_status authenticate message_for_status
#' @importFrom devtools github_pat
tag_table = function(repo, pat = NULL, ...) {
tag_table = function(
repo, pat = NULL,
mustWork = TRUE,
...) {
if (is.null(pat)) {
pat = devtools::github_pat(quiet = TRUE)
}
Expand All @@ -26,8 +32,15 @@ tag_table = function(repo, pat = NULL, ...) {

tag_url = paste0("https://api.github.com/repos/", repo, "/tags")
tag_res = httr::GET(tag_url, github_auth(pat), ...)


# args = list(url = tag_url)
get_tag_content = function(tag_res) {
if (!mustWork) {
if (httr::status_code(tag_res) > 400) {
return(NULL)
}
}
httr::stop_for_status(tag_res)
httr::message_for_status(tag_res)
tag_content = httr::content(tag_res)
Expand Down
14 changes: 9 additions & 5 deletions man/binary_release_table.Rd

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

6 changes: 5 additions & 1 deletion man/tag_table.Rd

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

0 comments on commit 5993dfc

Please sign in to comment.