fix(tools/git): -h/--help now exits 0 across 7 wrappers (#702)
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
ci/woodpecker/push/ci Pipeline was successful

This commit was merged in pull request #702.
This commit is contained in:
2026-07-11 09:23:46 +00:00
parent 4df38f7e81
commit a99aded26d
8 changed files with 67 additions and 14 deletions

View File

@@ -33,7 +33,7 @@ Examples:
$(basename "$0") -i 42 -l "in-progress" -m "0.2.0" $(basename "$0") -i 42 -l "in-progress" -m "0.2.0"
$(basename "$0") -i 42 -a @me $(basename "$0") -i 42 -a @me
EOF EOF
exit 1 exit "${1:-1}"
} }
# Parse arguments # Parse arguments
@@ -60,7 +60,7 @@ while [[ $# -gt 0 ]]; do
shift shift
;; ;;
-h|--help) -h|--help)
usage usage 0
;; ;;
*) *)
echo "Unknown option: $1" >&2 echo "Unknown option: $1" >&2

View File

@@ -72,7 +72,7 @@ Examples:
$(basename "$0") -t "Fix login bug" -l "bug,priority-high" $(basename "$0") -t "Fix login bug" -l "bug,priority-high"
$(basename "$0") -t "Add dark mode" -b "Implement theme switching" -m "0.2.0" $(basename "$0") -t "Add dark mode" -b "Implement theme switching" -m "0.2.0"
EOF EOF
exit 1 exit "${1:-1}"
} }
# Parse arguments # Parse arguments
@@ -95,7 +95,7 @@ while [[ $# -gt 0 ]]; do
shift 2 shift 2
;; ;;
-h|--help) -h|--help)
usage usage 0
;; ;;
*) *)
echo "Unknown option: $1" >&2 echo "Unknown option: $1" >&2

View File

@@ -36,7 +36,7 @@ Examples:
$(basename "$0") -m "0.2.0" # Issues in milestone 0.2.0 $(basename "$0") -m "0.2.0" # Issues in milestone 0.2.0
$(basename "$0") --repo ddk/ai-bma # List issues from anywhere $(basename "$0") --repo ddk/ai-bma # List issues from anywhere
EOF EOF
exit 1 exit "${1:-1}"
} }
# Parse arguments # Parse arguments
@@ -67,7 +67,7 @@ while [[ $# -gt 0 ]]; do
shift 2 shift 2
;; ;;
-h|--help) -h|--help)
usage usage 0
;; ;;
*) *)
echo "Unknown option: $1" >&2 echo "Unknown option: $1" >&2

View File

@@ -37,7 +37,7 @@ Examples:
$(basename "$0") -t "0.0.1" -d "Pre-MVP Foundation Sprint" $(basename "$0") -t "0.0.1" -d "Pre-MVP Foundation Sprint"
$(basename "$0") -t "0.1.0" -d "MVP Release" --due "2025-03-01" $(basename "$0") -t "0.1.0" -d "MVP Release" --due "2025-03-01"
EOF EOF
exit 1 exit "${1:-1}"
} }
# Parse arguments # Parse arguments
@@ -60,7 +60,7 @@ while [[ $# -gt 0 ]]; do
shift shift
;; ;;
-h|--help) -h|--help)
usage usage 0
;; ;;
*) *)
echo "Unknown option: $1" >&2 echo "Unknown option: $1" >&2

View File

@@ -86,7 +86,7 @@ Examples:
$(basename "$0") -i 42 -b "Implements the feature described in #42" $(basename "$0") -i 42 -b "Implements the feature described in #42"
$(basename "$0") -t "WIP: New feature" --draft $(basename "$0") -t "WIP: New feature" --draft
EOF EOF
exit 1 exit "${1:-1}"
} }
# Parse arguments # Parse arguments
@@ -125,7 +125,7 @@ while [[ $# -gt 0 ]]; do
shift shift
;; ;;
-h|--help) -h|--help)
usage usage 0
;; ;;
*) *)
echo "Unknown option: $1" >&2 echo "Unknown option: $1" >&2

View File

@@ -34,7 +34,7 @@ Examples:
$(basename "$0") -s merged -a username # Merged PRs by user $(basename "$0") -s merged -a username # Merged PRs by user
$(basename "$0") --repo ddk/ai-bma # List PRs from anywhere $(basename "$0") --repo ddk/ai-bma # List PRs from anywhere
EOF EOF
exit 1 exit "${1:-1}"
} }
# Parse arguments # Parse arguments
@@ -61,7 +61,7 @@ while [[ $# -gt 0 ]]; do
shift 2 shift 2
;; ;;
-h|--help) -h|--help)
usage usage 0
;; ;;
*) *)
echo "Unknown option: $1" >&2 echo "Unknown option: $1" >&2

View File

@@ -35,7 +35,7 @@ Examples:
$(basename "$0") -n 42 -d # Squash merge and delete branch $(basename "$0") -n 42 -d # Squash merge and delete branch
$(basename "$0") -n 42 --skip-queue-guard # Skip queue guard wait $(basename "$0") -n 42 --skip-queue-guard # Skip queue guard wait
EOF EOF
exit 1 exit "${1:-1}"
} }
# Parse arguments # Parse arguments
@@ -63,7 +63,7 @@ while [[ $# -gt 0 ]]; do
shift shift
;; ;;
-h|--help) -h|--help)
usage usage 0
;; ;;
*) *)
echo "Unknown option: $1" >&2 echo "Unknown option: $1" >&2

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Regression harness for #701: -h/--help must exit 0, bad args must still exit nonzero.
#
# Covers the 7 wrappers whose usage() previously hard-coded `exit 1`, so every
# --help invocation exited nonzero and logged a phantom isError across fleet lanes.
# Asserts, per wrapper:
# 1. `--help` exits 0 and prints usage.
# 2. `-h` exits 0 and prints usage.
# 3. A genuine unknown flag still exits nonzero (usage() default path untouched).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WRAPPERS=(
issue-assign.sh
issue-create.sh
issue-list.sh
milestone-create.sh
pr-create.sh
pr-list.sh
pr-merge.sh
)
fail=0
for wrapper in "${WRAPPERS[@]}"; do
path="$SCRIPT_DIR/$wrapper"
if ! output=$(bash "$path" --help 2>&1); then
echo "FAIL: $wrapper --help exited nonzero" >&2
fail=1
elif [[ "$output" != Usage:* ]]; then
echo "FAIL: $wrapper --help did not print usage" >&2
fail=1
fi
if ! bash "$path" -h >/dev/null 2>&1; then
echo "FAIL: $wrapper -h exited nonzero" >&2
fail=1
fi
if bash "$path" --this-is-not-a-real-flag >/dev/null 2>&1; then
echo "FAIL: $wrapper accepted an unknown flag (should have exited nonzero)" >&2
fail=1
fi
done
if [[ "$fail" -eq 0 ]]; then
echo "help-exit-code regression passed (7/7 wrappers)"
fi
exit "$fail"