Skip to content

Commit

Permalink
Add confirmation for rc_submit
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Mar 30, 2024
1 parent 618881c commit 532b87c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
31 changes: 30 additions & 1 deletion R/rc.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ rc_list_repos <- function(email = NULL) {
#' that corresponds to the email address, see [rc_new_token()].
#' If not specified (or `NULL`) then the email address of the package
#' maintainer is used.
#' @param confirmation You must set this to `TRUE` to submit a package
#' from a non-interactive session.
#' @return A list with data about the submission, invisibly.
#' Currently it has:
#'
Expand All @@ -112,7 +114,16 @@ rc_list_repos <- function(email = NULL) {
#' @family RC runners API
#' @seealso [rhub_platforms()] for a list of supported platforms.

rc_submit <- function(path = ".", platforms = NULL, email = NULL) {
rc_submit <- function(path = ".", platforms = NULL, email = NULL,
confirmation = NULL) {

if (isTRUE(confirmation) && !is_interactive()) {
throw(pkg_error(
"You need to set {.arg confirmation} to {.val TRUE}
to submit packages to R-hub from non-interactive R sessions."
))
}

pkg_name <- desc::desc_get("Package", file = path)[[1]]
if (is.na(pkg_name)) {
throw(pkg_error(
Expand Down Expand Up @@ -140,6 +151,24 @@ rc_submit <- function(path = ".", platforms = NULL, email = NULL) {
package = curl::form_file(path)
)

if (!isTRUE(confirmation)) {
cat(cli::col_cyan(cli::rule("Confirmation")))
cli::cli_bullets(c(
"!" = "Your package will be publicly readable at
{.url https://github.com/r-hub2}.",
" " = "Only continue if you are fine with this.",
" " = "See the {.fn rhub_setup} function for an alternative way
of using R-hub."
))
ans <- trimws(readline(
prompt = "\nPlease type 'yes' to continue: "
))
cli::cli_text()
if (ans != 'yes' && ans != "'yes'") {
throw(pkg_error("Aborted R-hub submission."))
}
}

resp <- query(
method = "POST",
ep,
Expand Down
5 changes: 4 additions & 1 deletion man/rc_submit.Rd

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

0 comments on commit 532b87c

Please sign in to comment.