feat: add auto-push functionality to commit and tag commands
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user