update syncing files with commits
This commit is contained in:
parent
99af64c259
commit
c753e40ffd
1 changed files with 31 additions and 12 deletions
|
|
@ -306,19 +306,38 @@ impl XBuilder {
|
|||
let commit = repo.find_commit(commit_id).expect("Failed to find commit");
|
||||
|
||||
let commit_time = commit.time();
|
||||
println!(
|
||||
"{}: {} > {} == {}",
|
||||
commit.id(),
|
||||
commit_time.seconds(),
|
||||
last_build_from_base,
|
||||
commit_time.seconds() >= last_build_from_base
|
||||
);
|
||||
// println!(
|
||||
// "{}: {} > {} == {}",
|
||||
// commit.id(),
|
||||
// commit_time.seconds(),
|
||||
// last_build_from_base,
|
||||
// commit_time.seconds() >= last_build_from_base
|
||||
// );
|
||||
if commit_time.seconds() >= last_build_from_base {
|
||||
println!(
|
||||
"Commit {} [{}]",
|
||||
commit.id(),
|
||||
commit.message().unwrap_or("-")
|
||||
);
|
||||
let tree = commit.tree().expect("Unable to get tree of commit");
|
||||
if let Some(parent) = commit.parent(0).ok() {
|
||||
let parent_tree = parent.tree().expect("Unable to get tree of parent");
|
||||
let diff = repo
|
||||
.diff_tree_to_tree(Some(&parent_tree), Some(&tree), None)
|
||||
.expect("Unable to diff trees");
|
||||
let dres = diff.foreach(
|
||||
&mut |delta, _| {
|
||||
if let Some(path) = delta.new_file().path() {
|
||||
let fpath = path.to_str().unwrap().to_string();
|
||||
if !result.contains(&fpath.clone()) {
|
||||
result.push(fpath);
|
||||
}
|
||||
}
|
||||
true
|
||||
},
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
);
|
||||
if dres.is_err() {
|
||||
eprintln!("Error while diffing trees: {}", dres.err().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue