Class: Ace::Git::Worktree::Molecules::CleanupReporter
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Molecules::CleanupReporter
- Defined in:
- lib/ace/git/worktree/molecules/cleanup_reporter.rb
Overview
Builds a complete, deterministic, report-only worktree cleanup inventory.
Inventories worktrees, local refs, and remote refs independently. Proves ancestry where possible. Produces an ordered no-mutation plan with a canonical SHA-256 digest.
Constant Summary collapse
- SCHEMA_VERSION =
"1.0"
Instance Method Summary collapse
-
#initialize(target:, remote: "origin", offline: false) ⇒ CleanupReporter
constructor
A new instance of CleanupReporter.
-
#report ⇒ Hash
Build complete cleanup report.
Constructor Details
#initialize(target:, remote: "origin", offline: false) ⇒ CleanupReporter
Returns a new instance of CleanupReporter.
24 25 26 27 28 |
# File 'lib/ace/git/worktree/molecules/cleanup_reporter.rb', line 24 def initialize(target:, remote: "origin", offline: false) @target = target @remote = remote @offline = offline end |
Instance Method Details
#report ⇒ Hash
Build complete cleanup report.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ace/git/worktree/molecules/cleanup_reporter.rb', line 32 def report common_dir = resolve_common_dir return error_result("Cannot resolve common git directory") unless common_dir target_sha = resolve_ref(@target) return error_result("Cannot resolve target ref '#{@target}'") unless target_sha remote_sha = resolve_ref("#{@remote}/#{@target}") # Refresh remote evidence (fetch objects only, no ref update) refresh_result = refresh_remote_evidence unless @offline # Collect inventories worktrees = inventory_worktrees(common_dir) local_refs = inventory_local_refs remote_refs = inventory_remote_refs pr_resolver = CleanupPrResolver.new(target: @target, target_sha: target_sha, offline: @offline) # Classify each item classify_worktrees(worktrees, target_sha, pr_resolver) classify_refs(local_refs, target_sha, "local", pr_resolver) classify_refs(remote_refs, target_sha, "remote", pr_resolver) # Build ordered action plan actions = build_action_plan(worktrees, local_refs, remote_refs) # Compute canonical digest plan_digest = compute_plan_digest(worktrees, local_refs, remote_refs, actions, target_sha) { success: true, schema_version: SCHEMA_VERSION, repository: common_dir, target: {ref: @target, sha: target_sha}, remote: {name: @remote, sha: remote_sha}, refresh: @offline ? {status: "offline"} : (refresh_result || {status: "skipped"}), worktrees: worktrees, local_refs: local_refs, remote_refs: remote_refs, actions: actions, plan_digest: plan_digest } end |