Skip to content

Merge refuses with 'Could not inspect the diff for CI workflow files' on ordinary merges #760

Closed

Description

@currentbits

What happens

Worktree merge (and PR merge) often shows the CI sign-off banner:

Could not inspect the diff for CI workflow files; merge refused.

Sign off & merge does not help. The change set usually does not touch any workflow file.

Why

gateCiWorkflowMerge (electron/worktrees.js) fail-closes when listChangedPaths cannot run git diff --name-only ${base}...HEAD.

base is the short name from defaultBranch (typically main via origin/HEAD). That three-dot spec fails when:

  • there is no local refs/heads/main and only origin/main exists (git rev-parse main exits 128)
  • the project checkout is detached (nightly/release worktree holds main) and the short name does not DWIM
  • HEAD is unborn, or the worktree directory is gone but thread.worktreePath is still set

The thrown message is prefixed CI_WORKFLOW:, so WorktreeControl treats a failed inspect as a privilege-escalation sign-off. Approving retries the same inspect and fails again. The real git stderr is swallowed.

Reproduced outside the app: after git checkout --detach && git branch -D main, git diff main...HEAD is unknown revision; git diff origin/main...HEAD succeeds.

Fix

  • Resolve the diff base to a real revision (main → origin/main / refs/remotes/origin/main) before the three-dot name-only list
  • Unborn HEAD: inspect the working tree only
  • Missing worktree dir: restore from the existing branch or throw a worktree-missing error, not a CI block
  • Inspect-failed must not use the CI_WORKFLOW: prefix (no Sign off button for a git failure)

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions