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 tree=repo.find_tree(tree_id)?;
|
||||||
|
|
||||||
|
let mut parents=Vec::new();
|
||||||
|
|
||||||
match repo.head(){
|
match repo.head(){
|
||||||
Ok(reference)=>repo.commit(
|
Ok(reference)=>parents.push(reference.peel_to_commit()?),
|
||||||
Some("HEAD"),//update_ref
|
Err(e)=>println!("repo head error {:?}",e),
|
||||||
&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
|
|
||||||
)?,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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
|
//commit
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user