Skip to content

Cleanup blocks on branches merged into non-main parent branches #1025

Description

@acreeger

Problem

When a branch's PR was merged into a non-main parent branch (e.g., a phase1 branch), il cleanup blocks with:

❌ Cannot cleanup:

Branch 'feat/issue-ai-44__preserve-chat-session' has not been pushed to remote and is not merged into 'develop'.
Deleting this branch would result in data loss.

Root Cause

The safety check flow in ResourceCleanup.ts (line ~950):

  1. getMergeTargetBranch() checks for parentLoom.branchName in metadata. If none, falls back to configured mainBranch (e.g., develop).
  2. GitHub deleted the remote branch after merge → remoteStatus.exists is false.
  3. Falls to isBranchMergedIntoMain(branch, mainBranch) which checks git merge-base --is-ancestor against develop.
  4. Branch was merged into a parent branch (not develop), so the check fails → blocked.

Workaround

il cleanup <identifier> --force bypasses the safety check.

Suggested Fix

When the remote branch doesn't exist and the branch isn't merged into the configured main branch, check via the VCS provider if a merged PR exists for this branch. If a merged PR exists, the work is safe — no data loss risk.

Relevant code:

  • src/lib/ResourceCleanup.ts:914-969 — safety check logic
  • src/utils/git.ts:1076-1100getMergeTargetBranch()
  • src/utils/git.ts:858-870isBranchMergedIntoMain()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions