write no empty commits
This commit is contained in:
parent
db44cf12be
commit
1bdfbf96c3
18
src/main.rs
18
src/main.rs
@ -752,6 +752,10 @@ async fn write_commit(config:WriteCommitConfig,b:Result<AResult<(AssetVersion,De
|
||||
let tree_id={
|
||||
let mut tree_index = repo.index()?;
|
||||
tree_index.add_all([config.output_folder].iter(),git2::IndexAddOption::DEFAULT,None)?;
|
||||
if tree_index.len()==0{
|
||||
println!("tree_index.len()==0");
|
||||
return Ok(());
|
||||
}
|
||||
tree_index.write_tree()?
|
||||
};
|
||||
let tree=repo.find_tree(tree_id)?;
|
||||
@ -759,7 +763,19 @@ async fn write_commit(config:WriteCommitConfig,b:Result<AResult<(AssetVersion,De
|
||||
let mut parents=Vec::new();
|
||||
|
||||
match repo.head(){
|
||||
Ok(reference)=>parents.push(reference.peel_to_commit()?),
|
||||
Ok(reference)=>{
|
||||
let commit=reference.peel_to_commit()?;
|
||||
|
||||
//test tree against commit tree to see if there is any changes
|
||||
let commit_tree=commit.tree()?;
|
||||
let diff=repo.diff_tree_to_tree(Some(&commit_tree),Some(&tree),None)?;
|
||||
if diff.deltas().count()==0{
|
||||
println!("no changes");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
parents.push(commit);
|
||||
},
|
||||
Err(e)=>println!("repo head error {:?}",e),
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user