1
0
mirror of https://github.com/shimunn/gitredditor.git synced 2023-11-17 18:42:43 +01:00

read index

This commit is contained in:
shimunn 2019-05-10 22:09:09 +02:00
parent f3e32bf1cb
commit e7751fa4b1

View File

@ -53,8 +53,10 @@ fn update<'a>(
let git = Repository::open(&repo)?; let git = Repository::open(&repo)?;
let sig = Signature::now(redditor, email)?; let sig = Signature::now(redditor, email)?;
let mut index = git.index()?; let mut index = git.index()?;
index.read(true)?;
let (threshold, threshold_percent) = threshold; let (threshold, threshold_percent) = threshold;
let threshold_percent = threshold_percent as f32; let threshold_percent = threshold_percent as f32;
let mut parent = dbg!(git.find_commit(git.head()?.target().unwrap()))?;
for comment in current.into_iter() { for comment in current.into_iter() {
let path = comment_path(&comment); let path = comment_path(&comment);
let path_rel = || { let path_rel = || {
@ -95,8 +97,6 @@ fn update<'a>(
let tree_id = index.write_tree()?; let tree_id = index.write_tree()?;
let tree = git.find_tree(tree_id)?; let tree = git.find_tree(tree_id)?;
let parent = dbg!(git.find_commit(git.head()?.target().unwrap()))?;
let time = { let time = {
let created = UNIX_EPOCH + Duration::from_secs(comment.created as u64); let created = UNIX_EPOCH + Duration::from_secs(comment.created as u64);
let edited = comment let edited = comment
@ -124,7 +124,7 @@ fn update<'a>(
)?; )?;
println!("Commiting: {}:\n{}", comment.id, commit_msg); println!("Commiting: {}:\n{}", comment.id, commit_msg);
git.commit( let commit = git.commit(
Some("HEAD"), Some("HEAD"),
&sig_backdate, &sig_backdate,
&sig, &sig,
@ -132,6 +132,7 @@ fn update<'a>(
&tree, &tree,
&[&parent], &[&parent],
)?; )?;
parent = git.find_commit(commit)?;
} }
} }
Ok(updated) Ok(updated)