mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 22:53:02 +02:00
Git support (#143)
This commit is contained in:
11
src-tauri/yaak-git/src/repository.rs
Normal file
11
src-tauri/yaak-git/src/repository.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use std::path::Path;
|
||||
use crate::error::Error::{GitRepoNotFound, GitUnknown};
|
||||
|
||||
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)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user