Skip to content

Commit f51066a

Browse files
fix: prevent double-bump in _phase_version_bump on interrupted resume (6ea9-a2af) (merge worktree-20260324-164324)
2 parents 3d79574 + 38187ef commit f51066a

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

plugins/dso/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dso",
3-
"version": "0.26.5",
3+
"version": "0.26.6",
44
"description": "Workflow infrastructure plugin for Claude Code projects",
55
"commands": "./commands/",
66
"skills": "./skills/",

plugins/dso/scripts/merge-to-main.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,15 @@ _phase_version_bump() {
11311131
_state_mark_complete "version_bump"; return 0; fi
11321132
local _bf="--${BUMP_TYPE:-patch}" _bs
11331133
_bs=$(command -v bump-version.sh 2>/dev/null || echo "${_SCRIPT_DIR:-${CLAUDE_PLUGIN_ROOT:-}/scripts}/bump-version.sh")
1134-
echo "Bumping version ($_bf)..."
1135-
if ! bash "$_bs" "$_bf" 2>&1; then echo 'ERROR: bump-version.sh failed. Fix version file before pushing.'; exit 1; fi
1134+
# Idempotency guard: if the version file is already bumped (modified on disk)
1135+
# from a prior interrupted attempt, skip bump-version.sh to avoid double-bump.
1136+
local _vf="${VERSION_FILE_PATH:-}"
1137+
if [[ -n "$_vf" && -f "$_vf" ]] && ! git diff --quiet -- "$_vf" 2>/dev/null; then
1138+
echo "INFO: version file already bumped (prior attempt) — skipping bump-version.sh."
1139+
else
1140+
echo "Bumping version ($_bf)..."
1141+
if ! bash "$_bs" "$_bf" 2>&1; then echo 'ERROR: bump-version.sh failed. Fix version file before pushing.'; exit 1; fi
1142+
fi
11361143
echo "OK: Version bumped."
11371144
git add -u 2>/dev/null || true
11381145
if ! git diff --cached --quiet 2>/dev/null; then git commit --amend --no-edit --quiet

tests/scripts/test-merge-to-main.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,5 +646,29 @@ assert_eq "test_merge_to_main_no_v2_tickets_dir_case" "0" "$HAS_V2_TICKETS_ARCHI
646646
HAS_TICKETS_DIR_V2=$(grep -cE 'TICKETS_DIR.*=.*"?\.tickets"?' "$MERGE_SCRIPT" || true)
647647
assert_eq "test_merge_to_main_no_TICKETS_DIR_tickets_path" "0" "$HAS_TICKETS_DIR_V2"
648648

649+
# =============================================================================
650+
# Test: _phase_version_bump checks for already-modified version file before bumping
651+
# Bug 6ea9-a2af: if bump-version.sh ran but git commit --amend failed, resume
652+
# would call bump-version.sh again (double-bump). The fix is to check whether the
653+
# version file is already modified before bumping.
654+
# =============================================================================
655+
echo "--- test_version_bump_idempotent_guard ---"
656+
_snapshot_fail
657+
# Look for a guard in _phase_version_bump that checks if version file is already modified
658+
# before calling bump-version.sh. The pattern: git diff or similar check before bump-version.sh
659+
_has_already_bumped_guard=0
660+
# Extract _phase_version_bump function body and check for a pre-bump guard
661+
# that detects an already-modified version file before calling bump-version.sh.
662+
# Must reference "already bumped" or check git diff on the version file.
663+
_vb_body=$(sed -n '/_phase_version_bump()/,/^}/p' "$MERGE_SCRIPT")
664+
# The pattern must appear AFTER the resume-skip block and BEFORE bump-version.sh call.
665+
# Filter out the "already completed (resume skip)" line — that's the state-file check, not the file-level guard.
666+
if echo "$_vb_body" | grep -v "resume skip" | grep -qE 'already.*bump|git diff.*version|version.*file.*modif'; then
667+
_has_already_bumped_guard=1
668+
fi
669+
assert_eq "test_version_bump_idempotent_guard: _phase_version_bump must check if version already bumped before calling bump-version.sh" \
670+
"1" "$_has_already_bumped_guard"
671+
assert_pass_if_clean "test_version_bump_idempotent_guard"
672+
649673
# =============================================================================
650674
print_summary

0 commit comments

Comments
 (0)