Skip to content
Merged
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
@@ -1,7 +1,7 @@
Type: Package
Package: audit.base
Title: Base package for Posit Checks
Version: 0.7.7
Version: 0.7.8
Authors@R:
person("Jumping", "Rivers", , "info@jumpingrivers.com", role = c("aut", "cre"))
Description: Base package for sharing classes between posit audit
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# audit.base 0.7.8 _2026-10-16_
* fix: `audit_posit_version()` and `get_quarto_posit_version_msg()` say the Posit version couldn't be found when it's `NA`, instead of erroring (jumpingrivers/audit.workbench#38)

# audit.base 0.7.7 _2026-10-16_
* fix: `clean_libs()` strips only the architecture from RHEL package names, so names with dots, such as `java-1.8.0-openjdk-devel`, `libgit2_1.7-devel` and `gdal3.4`, are no longer reported missing. `get_installed_libs()` lists names with `rpm -qa`, which also works on SUSE (#59)

Expand Down
11 changes: 10 additions & 1 deletion R/posit_versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ audit_posit_version = function(
type = c("connect", "workbench", "drivers")
) {
type = match.arg(type)
if (is_missing_version(posit_version)) {
cli::cli_alert_info("Couldn't find which version of Posit {type} is installed")
return(invisible(NULL))
}
versions = get_posit_versions(type = type)
row_number = lookup_version(posit_version, type = type)

Expand Down Expand Up @@ -107,13 +111,18 @@ lookup_version = function(posit_version, type) {

version_to_date = function(version) {
# Old style version
if (!is_new_version(version)) {
if (is_missing_version(version) || !is_new_version(version)) {
return(NA)
}
as_date = stringr::str_match_all(version, "^(202[0-9])\\.([01][0-9])")[[1]]
as.Date(paste(as_date[1, 2], as_date[1, 3], "01", sep = "-"))
}

# NA or character(0) when the version couldn't be found
is_missing_version = function(version) {
length(version) != 1L || is.na(version)
}

# Old style versions are 1.9.0 (2021-07)
is_new_version = function(version) {
stringr::str_detect(version, pattern = "^202[0-9]\\.[01][0-9].[0-9]")
Expand Down
3 changes: 3 additions & 0 deletions R/quarto-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ get_quarto_posit_version_msg = function(
type = c("connect", "workbench", "drivers")
) {
posit_version = out$posit_version
if (is_missing_version(posit_version)) {
return(glue::glue("We couldn't find which version of Posit {type} is installed."))
}
row_number = lookup_version(posit_version, type)
status = version_status(row_number)
if (status == "unknown") {
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-posit_versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ test_that("count_cves() counts each CVE once", {
expect_equal(count_cves(versions), 2L)
expect_equal(count_cves(versions[4, ]), 0L)
})

test_that("A version that couldn't be found is reported, not an error", {
for (version in list(NA_character_, character(0))) {
expect_message(audit_posit_version(version, "workbench"), "Couldn't find")
msg = get_quarto_posit_version_msg(list(posit_version = version), "workbench")
expect_match(msg, "couldn't find")
}
})
Loading