diff --git a/scripts/repo-sync b/scripts/repo-sync index 2d4dd64..f7bc7ab 100755 --- a/scripts/repo-sync +++ b/scripts/repo-sync @@ -22,6 +22,14 @@ current_branch="$("${git_cmd[@]}" branch --show-current)" echo "Git remote not found: ${remote}" >&2 exit 2 } +# OpenTofu leaves this transient lock metadata after an interrupted plan. It +# is safe to remove only when no OpenTofu process is still running; real source +# changes remain blocking as before. +stale_tofu_lock="${repo_root}/bootstrap/oci/.terraform.tfstate.lock.info" +if [[ -f "${stale_tofu_lock}" ]] && ! pgrep -af '[t]ofu' >/dev/null 2>&1; then + rm -f "${stale_tofu_lock}" + echo "Removed stale OpenTofu lock metadata: ${stale_tofu_lock}" +fi if [[ -n "$("${git_cmd[@]}" status --porcelain)" ]]; then echo "Refusing repo sync: working tree is not clean." >&2 "${git_cmd[@]}" status --short >&2