Skip to main content

gn_sync/
push.rs

1use anyhow::{Context, Result};
2use gn_core::Namespace;
3use std::path::Path;
4use std::process::Command;
5
6pub fn push_notes(repo_path: &Path, remote: &str, namespaces: &[Namespace]) -> Result<()> {
7    for ns in namespaces {
8        let ref_path = ns.ref_path();
9        let refspec = format!("{}:{}", ref_path, ref_path);
10
11        let status = Command::new("git")
12            .current_dir(repo_path)
13            .args(["push", remote, &refspec])
14            .status()
15            .with_context(|| format!("Failed to push namespace {}", ns))?;
16
17        if !status.success() {
18            // It might fail if there's nothing to push or refs don't exist, which could be normal.
19            // We can return an error or log a warning.
20            tracing::warn!("Push failed for namespace {}", ns);
21        }
22    }
23
24    Ok(())
25}