Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Suggests:
foghorn (>= 1.4.2),
gh (>= 1.3.0),
gmailr (>= 1.0.1),
httr (>= 1.4.3),
httr2 (>= 1.0.0),
knitr (>= 1.39),
lintr (>= 3.0.0),
MASS,
Expand Down
22 changes: 8 additions & 14 deletions R/check-mac.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,21 @@ check_mac_release <- function(

url <- "https://mac.r-project.org/macbuilder/v1/submit"

rlang::check_installed("httr")
body <- list(pkgfile = httr::upload_file(built_path))
rlang::check_installed("httr2")
body <- list(pkgfile = curl::form_file(built_path))

if (length(dep_built_paths) > 0) {
uploads <- lapply(dep_built_paths, httr::upload_file)
uploads <- lapply(dep_built_paths, curl::form_file)
names(uploads) <- rep("depfiles", length(uploads))
body <- append(body, uploads)
}

res <- httr::POST(
url,
body = body,
headers = list(
"Content-Type" = "multipart/form-data"
),
encode = "multipart"
)

httr::stop_for_status(res, task = "Uploading package")
req <- httr2::request(url) |>
httr2::req_body_multipart(!!!body) |>
httr2::req_headers(Accept = "application/json")
resp <- httr2::req_perform(req)

response_url <- httr::content(res)$url
response_url <- httr2::resp_body_json(resp)$url

if (!quiet) {
time <- strftime(Sys.time() + 10 * 60, "%I:%M %p")
Expand Down
36 changes: 12 additions & 24 deletions R/release.R
Original file line number Diff line number Diff line change
Expand Up @@ -297,35 +297,20 @@ upload_cran <- function(pkg, built_path, call = parent.frame()) {

# Initial upload ---------
cli::cli_inform(c(i = "Uploading package & comments"))
rlang::check_installed("httr")
rlang::check_installed("httr2")
body <- list(
pkg_id = "",
name = maint$name,
email = maint$email,
uploaded_file = httr::upload_file(built_path, "application/x-gzip"),
uploaded_file = curl::form_file(built_path, "application/x-gzip"),
comment = comments,
upload = "Upload package"
)
r <- httr::POST(cran_submission_url, body = body)

# If a 404 likely CRAN is closed for maintenance, try to get the message
if (httr::status_code(r) == 404) {
msg <- ""
try({
r2 <- httr::GET(sub("index2", "index", cran_submission_url))
msg <- extract_cran_msg(httr::content(r2, "text"))
})
cli::cli_abort(
c(
"*" = "Submission failed",
"x" = msg
),
call = call
)
}
req <- httr2::request(cran_submission_url) |>
httr2::req_body_multipart(!!!body)

httr::stop_for_status(r)
new_url <- httr::parse_url(r$url)
httr2::resp_check_status(resp)
new_url <- httr2::url_parse(httr2::resp_url(resp))

# Confirmation -----------
cli::cli_inform(c(i = "Confirming submission"))
Expand All @@ -336,9 +321,12 @@ upload_cran <- function(pkg, built_path, call = parent.frame()) {
policy_check = "1/",
submit = "Submit package"
)
r <- httr::POST(cran_submission_url, body = body)
httr::stop_for_status(r)
new_url <- httr::parse_url(r$url)
req <- do.call(
httr2::req_body_multipart,
c(list(httr2::request(cran_submission_url)), body)
)
resp <- httr2::req_perform(req)
new_url <- httr2::url_parse(httr2::resp_url(resp))
if (new_url$query$submit == "1") {
cli::cli_inform(c(
"v" = "Package submission successful",
Expand Down
6 changes: 2 additions & 4 deletions R/run-source.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@
source_url <- function(url, ..., sha1 = NULL) {
stopifnot(is.character(url), length(url) == 1)
rlang::check_installed("digest")
rlang::check_installed("httr")
rlang::check_installed("httr2")

temp_file <- file_temp()
on.exit(file_delete(temp_file), add = TRUE)

request <- httr::GET(url)
httr::stop_for_status(request)
writeBin(httr::content(request, type = "raw"), temp_file)
httr2::req_perform(httr2::request(url), path = temp_file)

check_sha1(temp_file, sha1)

Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ hadley
http
https
httr
httr2
hunspell
importFrom
initialising
Expand Down