diff --git a/lib/crates/fabro-workflows/src/git.rs b/lib/crates/fabro-workflows/src/git.rs index 46b2f22d9..dbd0430e2 100644 --- a/lib/crates/fabro-workflows/src/git.rs +++ b/lib/crates/fabro-workflows/src/git.rs @@ -259,25 +259,6 @@ pub fn branch_needs_push(repo: &Path, remote: &str, branch: &str) -> bool { } } -/// Assert the repo is clean and the current branch is pushed to the remote. -/// This is the check for remote sandboxes that clone from origin. -pub fn ensure_clean_and_pushed(repo: &Path, remote: &str, branch: Option<&str>) -> Result<()> { - ensure_clean(repo)?; - match branch { - Some(b) => { - tracing::debug!(path = %repo.display(), remote, branch = b, "Checking branch is pushed"); - if branch_needs_push(repo, remote, b) { - Err(git_error(format!( - "branch '{b}' has unpushed commits (not in sync with '{remote}/{b}')" - ))) - } else { - Ok(()) - } - } - None => Err(git_error("detached HEAD, cannot verify branch is pushed")), - } -} - /// Tri-state summary of the local repository's readiness for a workflow run. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum GitSyncStatus { @@ -1213,55 +1194,6 @@ mod tests { (repo_dir, remote_dir) } - #[test] - fn ensure_clean_and_pushed_when_clean_and_pushed() { - let dir = tempfile::tempdir().unwrap(); - let (repo_dir, _) = init_repo_with_remote(dir.path()); - assert!(ensure_clean_and_pushed(&repo_dir, "origin", Some("main")).is_ok()); - } - - #[test] - fn ensure_clean_and_pushed_when_dirty() { - let dir = tempfile::tempdir().unwrap(); - let (repo_dir, _) = init_repo_with_remote(dir.path()); - fs::write(repo_dir.join("dirty.txt"), "hello").unwrap(); - let err = ensure_clean_and_pushed(&repo_dir, "origin", Some("main")).unwrap_err(); - assert!(err.to_string().contains("uncommitted changes")); - } - - #[test] - fn ensure_clean_and_pushed_when_not_pushed() { - let dir = tempfile::tempdir().unwrap(); - let (repo_dir, _) = init_repo_with_remote(dir.path()); - - // Make another commit locally (now ahead of remote) - Command::new("git") - .args([ - "-c", - "user.name=test", - "-c", - "user.email=test@test", - "commit", - "--allow-empty", - "-m", - "unpushed", - ]) - .current_dir(&repo_dir) - .output() - .unwrap(); - - let err = ensure_clean_and_pushed(&repo_dir, "origin", Some("main")).unwrap_err(); - assert!(err.to_string().contains("unpushed commits")); - } - - #[test] - fn ensure_clean_and_pushed_when_no_branch() { - let dir = tempfile::tempdir().unwrap(); - let (repo_dir, _) = init_repo_with_remote(dir.path()); - let err = ensure_clean_and_pushed(&repo_dir, "origin", None).unwrap_err(); - assert!(err.to_string().contains("detached HEAD")); - } - #[test] fn metadata_branch_name_uses_meta_prefix() { assert_eq!(MetadataStore::branch_name("abc-123"), "fabro/meta/abc-123");