Skip to content

Commit

Permalink
Merge branch 'main' into filter-refs-by-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 30, 2022
2 parents 0f11a6d + 5dfa2cc commit a36c05d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions tests/tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static EXCLUDE_LUT: Lazy<Mutex<Option<git_worktree::fs::Cache<'static>>>> = Lazy
Mutex::new(cache)
});
/// The major, minor and patch level of the git version on the system.
pub static GIT_VERSION: Lazy<(u8, u8, u8)> = Lazy::new(|| parse_git_version().unwrap());
pub static GIT_VERSION: Lazy<(u8, u8, u8)> = Lazy::new(|| parse_git_version().expect("git version to be parsable"));

/// Define how [scripted_fixture_repo_writable_with_args()] uses produces the writable copy.
pub enum Creation {
Expand Down Expand Up @@ -105,11 +105,20 @@ fn parse_git_version() -> Result<(u8, u8, u8)> {
.map(|n| std::str::from_utf8(n).expect("valid utf8 in version number"))
.map(u8::from_str);

Ok((
numbers.next().expect("major")?,
numbers.next().expect("minor")?,
numbers.next().expect("patch")?,
))
Ok((|| -> Result<_> {
Ok((
numbers.next().expect("major")?,
numbers.next().expect("minor")?,
numbers.next().expect("patch")?,
))
})()
.map_err(|err| {
format!(
"Could not parse version from output of 'git --version' ({:?}) with error: {}",
output.stdout.to_str_lossy(),
err
)
})?)
}

/// Run `git` in `working_dir` with all provided `args`.
Expand Down

0 comments on commit a36c05d

Please sign in to comment.