huskies: merge 1199 story Orphaned build-dir GC: reclaim dead worktree targets without touching warm caches
This commit is contained in:
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
mod squash;
|
||||
|
||||
pub(crate) use squash::run_squash_merge;
|
||||
pub(crate) use squash::{merge_lock_is_free, run_squash_merge};
|
||||
|
||||
/// Typed outcome of a completed squash-merge operation.
|
||||
///
|
||||
|
||||
@@ -17,6 +17,19 @@ use crate::config::ProjectConfig;
|
||||
/// causing `git cherry-pick merge-queue/…` to fail with "bad revision".
|
||||
static MERGE_LOCK: Mutex<()> = Mutex::new(());
|
||||
|
||||
/// Returns `true` when no squash-merge is currently running, i.e. the merge
|
||||
/// lock is free.
|
||||
///
|
||||
/// Used by the build-directory GC pass (story 1199) to decide whether
|
||||
/// `.huskies/merge_workspace` is safe to reclaim. This is a best-effort,
|
||||
/// momentary check — the lock is not held across the reclaim itself, so a
|
||||
/// merge that starts immediately afterward can still race with GC. That's
|
||||
/// acceptable: the GC pass tolerates races and skips on error rather than
|
||||
/// failing the whole pass.
|
||||
pub(crate) fn merge_lock_is_free() -> bool {
|
||||
MERGE_LOCK.try_lock().is_ok()
|
||||
}
|
||||
|
||||
/// Resolve the base branch for `project_root` from config, or auto-detect it.
|
||||
fn resolve_base_branch(project_root: &Path) -> String {
|
||||
let configured = crate::config::ProjectConfig::load(project_root)
|
||||
|
||||
Reference in New Issue
Block a user