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:
- Field validation -- critical fields must be non-empty (
BranchType, FullBranchName, CurrentStep)
- Conflict steps (
merge, update_children) -- git must actually be in a merge or rebase state
- 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.
IsMergeInProgress()currently only checks whether.git/gitflow/state/merge.jsonexists. It doesn't validate whether the state is still meaningful. A stale state file causes confusing errors likeunknown branch type:(see #87) and could block other operations.How state becomes stale
git merge --abort,git checkout <branch>)Proposed solution
Add validation inside
IsMergeInProgress()so all callers benefit automatically.Checks:
BranchType,FullBranchName,CurrentStep)merge,update_children) -- git must actually be in a merge or rebase statecreate_tag,delete_branch) -- the topic branch referenced in the state must still existIf any check fails, clear the state file, print
Note: Cleared stale merge state from a previous operation, and returnfalse.