From 3aa1f5e915569e7d31d603b218c2f8f579fef2b3 Mon Sep 17 00:00:00 2001 From: louib Date: Wed, 20 Mar 2024 21:57:11 -0400 Subject: [PATCH] fix: do not panic on missing patch url --- src/cyclone_dx.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cyclone_dx.rs b/src/cyclone_dx.rs index e0bc01d..ff6e992 100644 --- a/src/cyclone_dx.rs +++ b/src/cyclone_dx.rs @@ -198,7 +198,17 @@ fn get_commits(patches: &Vec) -> Vec { let mut commits: Vec = vec![]; for patch in patches { let mut commit = CommitBuilder::default(); - commit.url(patch.get_url().unwrap()); + let commit_url = match patch.get_url() { + Some(u) => u, + None => { + log::warn!( + "No URL found for {}", + patch.get_name().unwrap_or("unknow derivation".to_string()) + ); + continue; + } + }; + commit.url(commit_url); // TODO we could also populate the uid, which is the commit SHA commits.push(commit.build().unwrap()) }