From 1bdfbf96c3548cece4318687d61119ded1b7423b Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 11 Jan 2024 20:33:12 -0800 Subject: [PATCH] write no empty commits --- src/main.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index adf5e7c..ab2e9c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -752,6 +752,10 @@ async fn write_commit(config:WriteCommitConfig,b:Resultparents.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), };