Refactor the release implementation into a dedicated workflow module with clear separation of concerns. Enforce a safe, deterministic Git flow by always syncing with the remote before modifications, pushing only the current branch and the newly created version tag, and updating the floating *latest* tag only when the released version is the highest. Add explicit user prompts for confirmation and optional branch deletion, with a forced mode to skip interaction. Update CLI wiring to pass all relevant flags, add comprehensive unit tests for the new helpers and workflow entry points, and introduce detailed documentation describing the release process, safety rules, and execution flow.
30 lines
828 B
Python
30 lines
828 B
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
|
|
def should_delete_branch(force: bool) -> bool:
|
|
"""
|
|
Ask whether the current branch should be deleted after a successful release.
|
|
|
|
- If force=True: skip prompt and return True.
|
|
- If non-interactive stdin: do NOT delete by default.
|
|
"""
|
|
if force:
|
|
return True
|
|
if not sys.stdin.isatty():
|
|
return False
|
|
answer = input("Delete the current branch after release? [y/N] ").strip().lower()
|
|
return answer in ("y", "yes")
|
|
|
|
|
|
def confirm_proceed_release() -> bool:
|
|
"""
|
|
Ask whether to proceed with the REAL release after the preview phase.
|
|
"""
|
|
try:
|
|
answer = input("Proceed with the actual release? [y/N]: ").strip().lower()
|
|
except (EOFError, KeyboardInterrupt):
|
|
return False
|
|
return answer in ("y", "yes")
|