feat: add auto-push functionality to commit and tag commands

This commit is contained in:
2026-02-01 12:35:26 +00:00
parent 0cbd975748
commit 09d2b6db8c
6 changed files with 131 additions and 27 deletions

View File

@@ -265,28 +265,18 @@ impl GitRepo {
/// Stage all changes including subdirectories
pub fn stage_all(&self) -> Result<()> {
let mut index = self.repo.index()?;
// Use git command for reliable staging (handles all edge cases)
let output = std::process::Command::new("git")
.args(&["add", "-A"])
.current_dir(&self.path)
.output()
.with_context(|| "Failed to stage changes with git command")?;
fn add_directory_recursive(index: &mut git2::Index, base_dir: &Path, current_dir: &Path) -> Result<()> {
for entry in std::fs::read_dir(current_dir)
.with_context(|| format!("Failed to read directory: {:?}", current_dir))?
{
let entry = entry?;
let path = entry.path();
if path.is_file() {
if let Ok(rel_path) = path.strip_prefix(base_dir) {
let _ = index.add_path(rel_path);
}
} else if path.is_dir() {
add_directory_recursive(index, base_dir, &path)?;
}
}
Ok(())
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
bail!("Failed to stage changes: {}", stderr);
}
add_directory_recursive(&mut index, &self.path, &self.path)?;
index.write()?;
Ok(())
}