From 5530e04661192d126218ab70a5d842149f40c270 Mon Sep 17 00:00:00 2001 From: wlandau-lilly Date: Mon, 21 Apr 2025 15:41:58 -0400 Subject: [PATCH] Allow review_pull_request() to get advisories and organizations if not supplied --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/review_pull_request.R | 14 ++++++++++++-- man/review_pull_request.Rd | 10 ++++++---- tests/testthat/test-update_status.R | 3 ++- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c4dbacce..b8e97939 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: multiverse.internals Title: Internal Infrastructure for R-multiverse Description: R-multiverse requires this internal infrastructure package to automate contribution reviews and populate universes. -Version: 1.0.9 +Version: 1.0.10 License: MIT + file LICENSE URL: https://r-multiverse.org/multiverse.internals/, diff --git a/NEWS.md b/NEWS.md index b61ee654..e807ce5a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# multiverse.internals 1.0.10 + +* Allow `review_pull_request()` to get advisories and organizations if not supplied. + # multiverse.internals 1.0.9 * Use `tools::analyze_license()` to determine if a package in a registration request has an open-source license. This is much more consistent and reliable than checking a manual list of license specification strings. diff --git a/R/review_pull_request.R b/R/review_pull_request.R index 4c2739cc..642eeb3c 100644 --- a/R/review_pull_request.R +++ b/R/review_pull_request.R @@ -9,19 +9,29 @@ #' in the repo. #' @param advisories Character vector of names of packages with advisories #' in the R Consortium Advisory Database. +#' If `NULL`, the function reads the database. #' @param organizations Character vector of names of GitHub organizations. #' Pull requests from authors who are not members of at least one of #' these organizations will be flagged for manual review. +#' If `NULL`, the function reads the list of trusted organizations. review_pull_request <- function( owner = "r-multiverse", repo = "contributions", number, - advisories = character(0L), - organizations = character(0L) + advisories = NULL, + organizations = NULL ) { assert_character_scalar(owner, "owner must be a character string") assert_character_scalar(repo, "repo must be a character string") assert_positive_scalar(number, "number must be a positive integer") + if (is.null(advisories)) { + message("Skimming the R Consortium Advisory Database...") + advisories <- unique(read_advisories()$package) + } + if (is.null(organizations)) { + message("Listing trusted GitHub organizations...") + organizations <- list_organizations(owner = owner, repo = repo) + } message("Reviewing pull request ", number) merge <- review_pull_request_integrity(owner, repo, number, organizations) && review_pull_request_content(owner, repo, number, advisories) diff --git a/man/review_pull_request.Rd b/man/review_pull_request.Rd index 5a04853f..748a000d 100644 --- a/man/review_pull_request.Rd +++ b/man/review_pull_request.Rd @@ -8,8 +8,8 @@ review_pull_request( owner = "r-multiverse", repo = "contributions", number, - advisories = character(0L), - organizations = character(0L) + advisories = NULL, + organizations = NULL ) } \arguments{ @@ -21,11 +21,13 @@ review_pull_request( in the repo.} \item{advisories}{Character vector of names of packages with advisories -in the R Consortium Advisory Database.} +in the R Consortium Advisory Database. +If \code{NULL}, the function reads the database.} \item{organizations}{Character vector of names of GitHub organizations. Pull requests from authors who are not members of at least one of -these organizations will be flagged for manual review.} +these organizations will be flagged for manual review. +If \code{NULL}, the function reads the list of trusted organizations.} } \value{ \code{NULL} (invisibly). diff --git a/tests/testthat/test-update_status.R b/tests/testthat/test-update_status.R index 3e375e3c..11c9d40c 100644 --- a/tests/testthat/test-update_status.R +++ b/tests/testthat/test-update_status.R @@ -31,7 +31,8 @@ test_that("update_status()", { path_status <- tempfile() gert::git_clone( url = "https://github.com/r-multiverse/status", - path = path_status + path = path_status, + verbose = FALSE ) on.exit(unlink(path_status, recursive = TRUE), add = TRUE) stage_candidates(path_staging = path_staging)