From b6a2a4212575127283af717d64dc302e14fd2980 Mon Sep 17 00:00:00 2001 From: adjenk <1632694+adjenk@users.noreply.github.com> Date: Tue, 8 Sep 2026 10:13:07 +0800 Subject: [PATCH] Added git why --version Why: no way to print the version today; single source of truth avoids drift from pyproject.toml Why-Spec: #1 --- git_why.py | 5 +++++ test/smoke.sh | 3 +++ 2 files changed, 8 insertions(+) diff --git a/git_why.py b/git_why.py index be510a3..8991ab5 100755 --- a/git_why.py +++ b/git_why.py @@ -18,6 +18,8 @@ import sys from fnmatch import fnmatch +__version__ = "0.1.0" # single source of truth; keep in sync with pyproject.toml + KEYS = ["Why", "Why-Prompt", "Why-Rationale", "Why-Alternatives", "Why-Spec", "Why-Agent", "Why-Session", "Why-Confidence"] LABEL = {"Why-Prompt": "prompt", "Why-Rationale": "rationale", @@ -413,6 +415,9 @@ def cmd_init(args): def main(): argv = sys.argv[1:] + if argv and argv[0] in ("-V", "--version"): + print(f"git why {__version__}") + return 0 if not argv or argv[0] not in SUBCOMMANDS: if argv and argv[0] in ("-h", "--help"): return cmd_show("-h") diff --git a/test/smoke.sh b/test/smoke.sh index bb6bed1..7f19708 100755 --- a/test/smoke.sh +++ b/test/smoke.sh @@ -22,6 +22,9 @@ git init -q git config user.email t@example.com git config user.name Tester +# --- version --------------------------------------------------------------- +gw --version | grep -qE "^git why [0-9]+\.[0-9]+" || fail "git why --version" + # --- default (substantial) enforcement ----------------------------------- gw init >/dev/null [ "$(git config --get why.strict)" = "substantial" ] || fail "default level not substantial"