refactor(cli): sweep 15 bail("git X") sites to use git_run with context labels

This commit is contained in:
adlee-was-taken
2026-05-08 22:10:25 -04:00
parent f3cdbed7b6
commit 97c8f994e1
6 changed files with 50 additions and 46 deletions

View File

@@ -78,11 +78,13 @@ pub fn cmd_purge(query: String) -> Result<()> {
vault.save_manifest(&manifest)?;
crate::refresh_groups_cache(vault.root(), &manifest);
let status = crate::helpers::git_command(vault.root(), &["add", "manifest.enc"]).status()?;
if !status.success() { anyhow::bail!("git add manifest.enc failed"); }
let status = crate::helpers::git_command(vault.root(),
&["commit", "-m", &format!("purge: {} ({})", title, id.as_str())]).status()?;
if !status.success() { anyhow::bail!("git commit failed"); }
let purge_ctx = format!("purge \"{}\" ({})", title, id.as_str());
crate::helpers::git_run(vault.root(), &["add", "manifest.enc"], &format!("{purge_ctx}: git add manifest.enc"))?;
crate::helpers::git_run(
vault.root(),
&["commit", "-m", &format!("purge: {} ({})", title, id.as_str())],
&format!("{purge_ctx}: git commit"),
)?;
Ok(())
}
@@ -121,11 +123,16 @@ pub fn cmd_trash_empty() -> Result<()> {
}
vault.save_manifest(&manifest)?;
let status = crate::helpers::git_command(vault.root(), &["add", "manifest.enc"]).status()?;
if !status.success() { anyhow::bail!("git add manifest.enc failed"); }
let status = crate::helpers::git_command(vault.root(),
&["commit", "-m", &format!("trash empty: purged {} item(s)", purged_titles.len())]).status()?;
if !status.success() { anyhow::bail!("git commit failed"); }
crate::helpers::git_run(
vault.root(),
&["add", "manifest.enc"],
"trash empty: git add manifest.enc",
)?;
crate::helpers::git_run(
vault.root(),
&["commit", "-m", &format!("trash empty: purged {} item(s)", purged_titles.len())],
"trash empty: git commit",
)?;
eprintln!("Emptied trash: {} item(s)", purged_titles.len());
Ok(())