Skip to content

Commit c8773f0

Browse files
authored
Merge pull request #83 from wlandau/main
fix FOSS license detection
2 parents 3507055 + 40e2a84 commit c8773f0

File tree

7 files changed

+36
-17
lines changed

7 files changed

+36
-17
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: multiverse.internals
22
Title: Internal Infrastructure for R-multiverse
33
Description: R-multiverse requires this internal infrastructure package to
44
automate contribution reviews and populate universes.
5-
Version: 1.0.10
5+
Version: 1.0.11
66
License: MIT + file LICENSE
77
URL:
88
https://r-multiverse.org/multiverse.internals/,

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# multiverse.internals 1.0.11
2+
3+
* Use `tools::analyze_license()` for continuous license checks because `utils::available.packages(repos = "https://community.r-multiverse.org", filters = "license/FOSS")` no longer returns output.
4+
* Strengthen continuous license checks: an `NA` license (from a failed source build) is no longer acceptable.
5+
16
# multiverse.internals 1.0.10
27

38
* Allow `review_pull_request()` to get advisories and organizations if not supplied.

R/assert_package_description.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ assert_parsed_description <- function(name, description) {
107107
)
108108
}
109109
license <- description$get("License")
110-
license_data <- tools::analyze_license(license)
111-
license_okay <- isTRUE(license_data$is_canonical) &&
112-
(isTRUE(license_data$is_FOSS) || isTRUE(license_data$is_verified))
113-
if (!license_okay) {
110+
if (!all(license_okay(license))) {
114111
return(
115112
paste(
116113
"Detected license",

R/issues_licenses.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
#' issues_licenses()
1010
#' }
1111
issues_licenses <- function(meta = meta_packages()) {
12-
meta$foss[is.na(meta$foss)] <- TRUE
12+
meta$foss[is.na(meta$foss)] <- FALSE # deliberately redundant
1313
meta[!meta$foss, c("package", "license"), drop = FALSE]
1414
}

R/meta_packages.R

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ meta_packages <- function(repo = "https://community.r-multiverse.org") {
1313
meta_api <- get_meta_api(repo)
1414
meta_json <- get_meta_json(repo)
1515
meta_cran <- get_meta_cran()
16-
foss <- get_foss(repo)
1716
data <- merge(x = meta_api, y = meta_json, all.x = TRUE, all.y = FALSE)
1817
data <- merge(x = data, y = meta_cran, all.x = TRUE, all.y = FALSE)
19-
data$foss[data$package %in% foss] <- TRUE
18+
data$license[is.na(data$license)] <- "NOT FOUND"
19+
data$foss <- get_foss(data$license)
2020
data
2121
}
2222

@@ -34,19 +34,26 @@ get_meta_json <- function(repo) {
3434
simplifyMatrix = TRUE
3535
)
3636
data <- clean_meta(data)
37-
data$foss <- FALSE
3837
if (is.null(data$remote)) {
3938
data$remotes <- replicate(nrow(data), NULL, simplify = FALSE)
4039
}
41-
data[, c("package", "remotes", "foss")]
40+
data[, c("package", "remotes")]
4241
}
4342

44-
get_foss <- function(repo) {
45-
data <- utils::available.packages(
46-
repos = trim_url(repo),
47-
filters = "license/FOSS"
43+
get_foss <- function(license) {
44+
license <- trimws(license)
45+
foss <- rep(FALSE, length(license))
46+
# Pre-compute most common license types because tools::analyze_license()
47+
# is slow to iterate on large vectors of license specifications.
48+
common <- c(
49+
"MIT + file LICENSE",
50+
"GPL-3",
51+
"GPL-2"
4852
)
49-
as.character(data[, "Package"])
53+
is_common <- foss %in% common
54+
foss[is_common] <- TRUE
55+
foss[!is_common] <- license_okay(license[!is_common])
56+
foss
5057
}
5158

5259
get_meta_cran <- function() {

R/utils_license.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
license_okay <- Vectorize(
2+
function(license) {
3+
license_data <- tools::analyze_license(license)
4+
isTRUE(license_data$is_canonical) &&
5+
(isTRUE(license_data$is_FOSS) || isTRUE(license_data$is_verified))
6+
},
7+
"license",
8+
USE.NAMES = FALSE
9+
)

tests/testthat/helper-mock.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ mock_meta_packages <- structure(list(
928928
"MIT + file LICENSE", "MIT + file LICENSE", "MIT + file LICENSE",
929929
"MIT + file LICENSE", "MIT + file LICENSE", "MIT + file LICENSE",
930930
"AGPL-3", "MIT + file LICENSE", "GPL (>= 2)", "GPL (>= 3)",
931-
"GPL (>= 2)", "MIT + file LICENSE", NA, "MIT + file LICENSE",
931+
"GPL (>= 2)", "MIT + file LICENSE", "NOT FOUND", "MIT + file LICENSE",
932932
"MIT + file LICENSE", "MIT + file LICENSE", "MIT + file LICENSE",
933933
"MIT + file LICENSE", "GPL (>= 3)", "MIT + file LICENSE",
934934
"MIT + file LICENSE", "Apache License (>= 2)", "GPL (>= 3)",
@@ -1063,7 +1063,7 @@ mock_meta_packages <- structure(list(
10631063
TRUE, TRUE, TRUE, TRUE,
10641064
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
10651065
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
1066-
NA, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
1066+
FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
10671067
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
10681068
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE
10691069
), cran = c(
@@ -1228,6 +1228,7 @@ mock_status <- list(
12281228
success = FALSE,
12291229
published = "2025-03-06 02:51:02.348 UTC", version = "19.09.03",
12301230
remote_hash = "0fa332471d2e19548cc0f63e36873e31dbd685be",
1231+
license = "NOT FOUND",
12311232
r_cmd_check = list(issues = list(
12321233
linux = "MISSING", mac = "MISSING",
12331234
win = "MISSING", source = "FAILURE"

0 commit comments

Comments
 (0)