Skip to content

Detect and auto-clear stale merge state #101

Description

@alexrinass

IsMergeInProgress() currently only checks whether .git/gitflow/state/merge.json exists. It doesn't validate whether the state is still meaningful. A stale state file causes confusing errors like unknown branch type: (see #87) and could block other operations.

How state becomes stale

Proposed solution

Add validation inside IsMergeInProgress() so all callers benefit automatically.

Checks:

  1. Field validation -- critical fields must be non-empty (BranchType, FullBranchName, CurrentStep)
  2. Conflict steps (merge, update_children) -- git must actually be in a merge or rebase state
  3. Non-conflict steps (create_tag, delete_branch) -- the topic branch referenced in the state must still exist

If any check fails, clear the state file, print Note: Cleared stale merge state from a previous operation, and return false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions