Skip to content

Commit

Permalink
deps: Update
Browse files Browse the repository at this point in the history
`rev_lines` API changed, now iterates over a `Result<String, _>` rather than a `String`, so we need
to be a bit more explicit.

Updating anstyle v1.0.0 -> v1.0.1
Updating rev_lines v0.2.2 -> v0.3.0
  Adding thiserror v1.0.40
  Adding thiserror-impl v1.0.40
  • Loading branch information
vincentdephily committed Jun 23, 2023
1 parent 1127625 commit 676519c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
31 changes: 27 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env_logger = { version = "0.10.0", default-features = false }
libc = { version = "0.2.126", default-features = false }
log = "0.4.11"
regex = { version = "1.3.9", default_features = false, features = ["std", "perf-inline", "perf-literal", "unicode-case"] }
rev_lines = "0.2.1"
rev_lines = "0.3.0"
serde = { version = "1.0.147", features = ["derive"] }
serde_json = "1.0.89"
time = {version = "0.3.5", features = ["parsing", "formatting", "local-offset", "macros"]}
Expand Down
15 changes: 7 additions & 8 deletions src/parse/current.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ pub fn get_buildlog(pkg: &Pkg, portdir: &str) -> Option<String> {
let name = format!("{}/portage/{}/temp/build.log", portdir, pkg.ebuild_version());
info!("Build log: {name}");
let file = File::open(&name).map_err(|e| warn!("Cannot open {name:?}: {e}")).ok()?;
read_buildlog(file, 50)
Some(read_buildlog(file, 50))
}
fn read_buildlog(file: File, max: usize) -> Option<String> {
fn read_buildlog(file: File, max: usize) -> String {
let mut last = String::new();
for line in rev_lines::RevLines::new(BufReader::new(file)).ok()? {
for line in rev_lines::RevLines::new(BufReader::new(file)).map_while(Result::ok) {
if line.starts_with(">>>") {
let tag = line.split_ascii_whitespace().skip(1).take(2).collect::<Vec<_>>().join(" ");
if last.is_empty() {
return Some(format!(" ({})", tag.trim_matches('.')));
return format!(" ({})", tag.trim_matches('.'));
} else {
return Some(format!(" ({}: {})", tag.trim_matches('.'), last));
return format!(" ({}: {})", tag.trim_matches('.'), last);
}
}
if last.is_empty() {
Expand All @@ -115,7 +115,7 @@ fn read_buildlog(file: File, max: usize) -> Option<String> {
}
}
}
Some(format!(" ({last})"))
format!(" ({last})")
}

#[cfg(test)]
Expand Down Expand Up @@ -198,8 +198,7 @@ mod tests {
("build.log.color", 15, "Unpacking source: 0:57.55 Comp...")]
{
let f = File::open(&format!("tests/{file}")).expect(&format!("can't open {file:?}"));
let s = read_buildlog(f, lim).expect("failed to read_buildlog");
assert_eq!(format!(" ({res})"), s);
assert_eq!(format!(" ({res})"), read_buildlog(f, lim));
}
}
}

0 comments on commit 676519c

Please sign in to comment.