mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-19 07:54:23 +01:00
11 lines
372 B
Rust
11 lines
372 B
Rust
use crate::error::Error::{GitRepoNotFound, GitUnknown};
|
|
use std::path::Path;
|
|
|
|
pub(crate) fn open_repo(dir: &Path) -> crate::error::Result<git2::Repository> {
|
|
match git2::Repository::discover(dir) {
|
|
Ok(r) => Ok(r),
|
|
Err(e) if e.code() == git2::ErrorCode::NotFound => Err(GitRepoNotFound(dir.to_path_buf())),
|
|
Err(e) => Err(GitUnknown(e)),
|
|
}
|
|
}
|