feat: ignore submodules in git dependencies

Previously, if a repository contained a submodule
pesde would throw an error since there is no
entries for them. Now, they are simply ignored.
This commit is contained in:
daimond113 2025-02-01 16:25:00 +01:00
parent ca550eee3a
commit 24049d60a2
No known key found for this signature in database
GPG key ID: 640DC95EC1190354

View file

@ -388,7 +388,7 @@ impl PackageSource for GitPackageSource {
let object = match repo.find_object(tree_id) {
Ok(object) => object,
Err(e) => {
return Err(errors::DownloadError::ParseOidToObject(
return Err(errors::DownloadError::OidToTree(
tree_id,
Box::new(repo_url),
e,
@ -413,6 +413,11 @@ impl PackageSource for GitPackageSource {
recorder
.records
.into_iter()
.filter(|entry| {
// we do not support submodules, so we filter them out so
// find_object does not error
entry.mode.kind() != gix::object::tree::EntryKind::Commit
})
.map(|entry| {
let object = repo.find_object(entry.oid).map_err(|e| {
errors::DownloadError::ParseOidToObject(
@ -652,6 +657,14 @@ pub mod errors {
#[source] gix::traverse::tree::breadthfirst::Error,
),
/// Getting the tree by object id failed
#[error("error getting tree from object id {0} for repository {1}")]
OidToTree(
ObjectId,
Box<gix::Url>,
#[source] gix::object::find::existing::Error,
),
/// An error occurred parsing an object id to object
#[error("error parsing object id {0} to object for repository {1}")]
ParseOidToObject(