From d95cbdb7386e8e7605ae4d8d3de2b4565832d0f4 Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Fri, 30 Jun 2023 17:25:03 +0200 Subject: [PATCH] fetch after push --- src-tauri/src/virtual_branches/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src-tauri/src/virtual_branches/mod.rs b/src-tauri/src/virtual_branches/mod.rs index f4c98ec9b..39d03a9fa 100644 --- a/src-tauri/src/virtual_branches/mod.rs +++ b/src-tauri/src/virtual_branches/mod.rs @@ -1508,6 +1508,7 @@ pub fn push( branch_writer .write(&vbranch) .context("failed to write target branch after push")?; + fetch(project_path).context("failed to fetch after push")?; Ok(()) } else { 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)] mod tests { use tempfile::tempdir;