Allow for staging and unstaging in git management view

This commit is contained in:
Jeremy Soller 2024-05-14 11:45:39 -06:00
parent a481bb342d
commit 4716c2242b
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
4 changed files with 293 additions and 180 deletions

View file

@ -262,4 +262,23 @@ impl GitRepository {
Ok(status)
}
pub async fn stage<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
let path = path.as_ref();
let mut command = self.command();
command.arg("stage");
command.arg("--").arg(path);
Self::command_stdout(command).await?;
Ok(())
}
pub async fn unstage<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
let path = path.as_ref();
let mut command = self.command();
command.arg("restore");
command.arg("--staged");
command.arg("--").arg(path);
Self::command_stdout(command).await?;
Ok(())
}
}