Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qgis_query_version(): don't require the commit hash for regular releases #118

Merged
merged 11 commits into from
Jan 11, 2023
Merged
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ License: GPL-3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.2
Imports:
processx (>= 3.5.2),
stringr,
Expand Down
21 changes: 16 additions & 5 deletions R/qgis-configure.R
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,29 @@ qgis_query_version <- function(quiet = FALSE) {
lines <- readLines(textConnection(result$stdout))
match <- stringr::str_match(
lines,
"QGIS\\s(\\d{1,2}\\.\\d+.*-\\p{L}+)\\s.*\\(([0-9a-f]{8,})\\)"
"QGIS\\s(\\d{1,2}\\.\\d+.*-\\p{L}+)\\s.*\\((.+)\\)"
)[, 2:3, drop = TRUE]
match <- match[!is.na(match)]
if (length(match) == 0L) abort_query_version(lines = lines)
if (
stringr::str_detect(match[1], "[Mm]aster") ||
stringr::str_detect(match[1], "^\\d{1,2}\\.\\d*[13579][\\.-]")
!stringr::str_detect(match[1], "-[Mm]a(ster|in)$") &&
!stringr::str_detect(match[1], "^\\d{1,2}\\.\\d*[13579][\\.-]")
) {
return(match[1])
} else {
if (length(match) < 2L) abort_query_version(lines = lines)
if (!stringr::str_detect(match[2], "^[0-9a-f]{7,}$")) {
warning("Please consider building the QGIS development version from ",
"within the QGIS git repository, in order to have a unique ",
"version identifier of QGIS, or propose the people making the ",
"QGIS build to do so. ",
"Currently the specific version identifier is '",
match[2],
"'.",
call. = TRUE)
match[2] <- paste("unclear:", match[2])
}
return(paste0(match[1], ", development state ", match[2]))
} else {
return(match[1])
}
}

Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-qgis-configure.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ test_that("qgis_query_version() works for development versions of QGIS", {

expect_match(
qversion,
"^\\d{1,2}\\.\\d+.*-\\p{L}+, development state [0-9a-f]{8,}",
"^\\d{1,2}\\.\\d+.*-\\p{L}+, development state ([0-9a-f]{7,}|unclear:.+)",
perl = TRUE
)

if (stringr::str_detect(qversion, ".+development state unclear:.+")) {
expect_warning(qgis_query_version(), "version identifier")
}
})

test_that("qgis_algorithms() works", {
Expand Down