Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libwalker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub struct DiffList<'w> {
pub struct CommitDiffs {
pub commit: Oid,

pub count: u64,

pub path_diffs: Vec<PathBuf>,
}

Expand Down Expand Up @@ -65,9 +67,13 @@ impl Walker {

revwalk.push_head()?;

let mut count = 0u64;

let mut spec_diffs = Vec::new();

for oid in revwalk {
count += 1;

let oid = oid?;

let commit = self.repo.find_commit(oid)?;
Expand Down Expand Up @@ -105,6 +111,7 @@ impl Walker {
if !diff_stems.is_empty() {
spec_diffs.push(CommitDiffs {
commit: commit.id(),
count,
path_diffs: diff_stems,
});
}
Expand All @@ -126,6 +133,8 @@ impl Walker {
pub struct BlobContent {
pub commit: Oid,

pub count: u64,

pub time: i64,

pub path: PathBuf,
Expand Down Expand Up @@ -154,6 +163,7 @@ impl<'w> Iterator for DiffList<'w> {

bcs.push(BlobContent {
commit: spec_diff.commit,
count: spec_diff.count,
time: commit.time().seconds(),
path: path.to_owned(),
content,
Expand Down
2 changes: 2 additions & 0 deletions libwalker/tests/sm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ fn test_walk() -> Result<(), Box<dyn std::error::Error>> {

for t in spec_diffs {
for c in t {
println!("{} {}", c.commit, c.count);

std::fs::write(
format!("tests/contents/{}", c.commit.to_string()),
c.content,
Expand Down