Skip to main content

provenant/
version.rs

1// SPDX-FileCopyrightText: Provenant contributors
2// SPDX-License-Identifier: Apache-2.0
3
4use std::sync::OnceLock;
5
6pub const BUILD_VERSION: &str = match option_env!("PROVENANT_BUILD_VERSION") {
7    Some(version) => version,
8    None => env!("CARGO_PKG_VERSION"),
9};
10
11const ATTRIBUTION_NOTICE: &str = "Independent project; not affiliated with, endorsed by, or sponsored by ScanCode Toolkit, AboutCode, or nexB Inc. License detection uses data from ScanCode Toolkit (CC-BY-4.0). See NOTICE file or the show-attribution command.";
12
13pub fn build_long_version() -> &'static str {
14    static LONG_VERSION: OnceLock<String> = OnceLock::new();
15
16    LONG_VERSION
17        .get_or_init(|| format!("{BUILD_VERSION}\n{ATTRIBUTION_NOTICE}"))
18        .as_str()
19}
20
21#[cfg(test)]
22mod tests {
23    #[test]
24    fn test_long_version_mentions_independence_and_attribution() {
25        let version = super::build_long_version();
26
27        assert!(version.contains("Independent project"));
28        assert!(version.contains("ScanCode Toolkit (CC-BY-4.0)"));
29    }
30}