empty-descriptions-and-dropped-worktrees #15

Merged
seb merged 10 commits from empty-descriptions-and-dropped-worktrees into main 2025-07-10 09:48:22 -06:00
Showing only changes of commit ac72251e0e - Show all commits

View file

@ -117,6 +117,19 @@ pub fn worktree_is_dirty(dir: &str) -> Result<bool, GitError> {
return Ok(result.stdout.len() > 0); return Ok(result.stdout.len() > 0);
} }
pub fn restore_file(file: &std::path::Path) -> Result<(), GitError> {
let result = std::process::Command::new("git")
.args(["restore", &file.to_string_lossy()])
.current_dir(file.parent().unwrap())
.output()?;
if !result.status.success() {
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
return Err(GitError::Oops);
}
return Ok(());
}
pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> { pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> {
let mut git_dir = std::path::PathBuf::from(file); let mut git_dir = std::path::PathBuf::from(file);
git_dir.pop(); git_dir.pop();