mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-27 02:58:34 +02:00
Move a bunch of git ops to use the git binary (#302)
This commit is contained in:
16
src-tauri/yaak-git/src/add.rs
Normal file
16
src-tauri/yaak-git/src/add.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use crate::error::Result;
|
||||
use crate::repository::open_repo;
|
||||
use git2::IndexAddOption;
|
||||
use log::info;
|
||||
use std::path::Path;
|
||||
|
||||
pub(crate) fn git_add(dir: &Path, rela_path: &Path) -> Result<()> {
|
||||
let repo = open_repo(dir)?;
|
||||
let mut index = repo.index()?;
|
||||
|
||||
info!("Staging file {rela_path:?} to {dir:?}");
|
||||
index.add_all(&[rela_path], IndexAddOption::DEFAULT, None)?;
|
||||
index.write()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user