Skip to content

Use {httr2}, not {httr} #2148

Closed
Closed

Description

@MichaelChirico

{httr} is superseded in favor of {httr2}. We don't have much usage, so it should be "easy" to refactor in favor of the newer/better-supported package:

lintr/R/comments.R

Lines 85 to 115 in 203be65

github_comment <- function(text, info = NULL, token = settings$comment_token) {
if (!requireNamespace("httr", quietly = TRUE)) {
stop("Package 'httr' is required to post comments with github_comment().")
}
if (!requireNamespace("jsonlite", quietly = TRUE)) {
stop("Package 'jsonlite' is required to post comments with github_comment().")
}
if (is.null(info)) {
info <- ci_build_info()
}
if (!is.null(info$pull) && info$pull != "false") {
api_subdir <- file.path("issues", info$pull)
} else if (!is.null(info$commit)) {
api_subdir <- file.path("commits", info$commit)
} else {
stop("Expected a pull or a commit, but received ci_build_info() = ", format(info))
}
response <- httr::POST(
"https://api.github.com",
path = file.path("repos", info$user, info$repo, api_subdir, "comments"),
body = list(body = jsonlite::unbox(text)),
query = list(access_token = token),
encode = "json"
)
if (httr::status_code(response) >= 300L) {
message(httr::http_condition(response, "error", task = httr::content(response, as = "text")))
}
}

Activity

  1. added
    internals
    on Sep 12, 2023
  2. added this to the 3.1.2 milestone on Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    internals

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions