Skip to content

Commit b76d7d5

Browse files
committed
Replace license-exprs crate with spdx
1 parent ee38010 commit b76d7d5

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Cargo.lock

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ hyper = { version = "0.14", features = ["client", "http1"] }
6363
indexmap = { version = "1.7.0", features = ["serde-1"] }
6464
tikv-jemallocator = { version = "0.4.1", features = ['unprefixed_malloc_on_supported_platforms', 'profiling'] }
6565
lettre = { version = "0.10.0-rc.4", default-features = false, features = ["file-transport", "smtp-transport", "native-tls", "hostname", "builder"] }
66-
license-exprs = "1.6"
66+
spdx = "=0.7.0"
6767
minijinja = "0.8.2"
6868
moka = "0.6.1"
6969
oauth2 = { version = "4.1.0", default-features = false, features = ["reqwest"] }

src/models/version.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ impl NewVersion {
190190

191191
fn validate_license_expr(s: &str) -> AppResult<()> {
192192
for part in s.split('/') {
193-
license_exprs::validate_license_expr(part).map_err(|e| {
194-
cargo_err(&format_args!("{}; see http://opensource.org/licenses for options, and http://spdx.org/licenses/ for their identifiers", e))
193+
spdx::Expression::parse(part).map_err(|_| {
194+
cargo_err("unknown or invalid license expression; see http://opensource.org/licenses for options, and http://spdx.org/licenses/ for their identifiers")
195195
})?;
196196
}
197197

@@ -277,13 +277,10 @@ mod tests {
277277
assert_ok!(validate_license_expr("MIT OR Apache-2.0"));
278278
assert_ok!(validate_license_expr("MIT/Apache-2.0"));
279279
assert_ok!(validate_license_expr("MIT AND Apache-2.0"));
280+
assert_ok!(validate_license_expr("MIT OR (Apache-2.0 AND MIT)"));
280281

281282
let error = assert_err!(validate_license_expr("apache 2.0"));
282283
let error = format!("{}", error);
283-
assert!(error.starts_with("unknown license or other term: apache; see http"));
284-
285-
let error = assert_err!(validate_license_expr("MIT OR (Apache-2.0 AND MIT)"));
286-
let error = format!("{}", error);
287-
assert!(error.starts_with("unknown license or other term: (Apache-2.0; see http"));
284+
assert!(error.starts_with("unknown or invalid license expression; see http"));
288285
}
289286
}

0 commit comments

Comments
 (0)