cargo-allow 0.1.3

Source-tree exception ledger and policy scanner for Rust repositories.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use allow_core::normalize_path;
use allow_policy::{EvidenceReferenceDiagnostic, EvidenceReferenceStatus};

pub(crate) fn evidence_reference_target_text(
    diagnostic: &EvidenceReferenceDiagnostic,
) -> Option<String> {
    diagnostic.target.as_ref().map(|target| {
        if diagnostic.status == EvidenceReferenceStatus::InvalidLocalPath {
            target.to_string_lossy().replace('\\', "/")
        } else {
            normalize_path(target)
        }
    })
}