mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-07 08:27:12 +00:00
Remove dead ensure_clean_and_pushed function
This function had zero callers after sync_status was introduced in
a5273e17. Remove it along with its four tests.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e3b396e001
commit
ce313f56a4
1 changed files with 0 additions and 68 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue