fix code duplication

This commit is contained in:
Quaternions 2024-01-11 20:33:04 -08:00
parent 30169ddc5b
commit db44cf12be

View File

@ -756,25 +756,22 @@ async fn write_commit(config:WriteCommitConfig,b:Result<AResult<(AssetVersion,De
};
let tree=repo.find_tree(tree_id)?;
let mut parents=Vec::new();
match repo.head(){
Ok(reference)=>repo.commit(
Some("HEAD"),//update_ref
&sig,//author
&sig,//commiter
&format!("v{}", asset_version.assetVersionNumber),//message
&tree,//tree (basically files)
&[&reference.peel_to_commit()?],//parents
)?,
Err(_)=>repo.commit(
Some("HEAD"),//update_ref
&sig,//author
&sig,//commiter
&format!("v{}", asset_version.assetVersionNumber),//message
&tree,//tree (basically files)
&[],//parents
)?,
Ok(reference)=>parents.push(reference.peel_to_commit()?),
Err(e)=>println!("repo head error {:?}",e),
};
repo.commit(
Some("HEAD"),//update_ref
&sig,//author
&sig,//commiter
&format!("v{}", asset_version.assetVersionNumber),//message
&tree,//tree (basically files)
parents.iter().collect::<Vec<&git2::Commit<'_>>>().as_slice(),//parents
)?;
//commit
Ok(())
}