fetch after push

This commit is contained in:
Kiril Videlov 2023-06-30 17:25:03 +02:00 committed by Kiril Videlov
parent 488f7862f5
commit d95cbdb738

View File

@ -1508,6 +1508,7 @@ pub fn push(
branch_writer branch_writer
.write(&vbranch) .write(&vbranch)
.context("failed to write target branch after push")?; .context("failed to write target branch after push")?;
fetch(project_path).context("failed to fetch after push")?;
Ok(()) Ok(())
} else { } else {
Err(anyhow::anyhow!( Err(anyhow::anyhow!(
@ -1517,6 +1518,24 @@ pub fn push(
} }
} }
fn fetch(project_path: &str) -> Result<()> {
let output = Command::new("git")
.arg("fetch")
.arg("origin")
.current_dir(project_path)
.output()
.context("failed to fork exec")?;
if output.status.success() {
Ok(())
} else {
Err(anyhow::anyhow!(
"failed to fetch: {}",
String::from_utf8(output.stderr)?
))
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use tempfile::tempdir; use tempfile::tempdir;