forked from StrafesNET/asset-tool
fix code duplication
This commit is contained in:
parent
30169ddc5b
commit
db44cf12be
29
src/main.rs
29
src/main.rs
@ -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(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user