Skip to content

Commit 7dd314f

Browse files
nsheapsclaude
andcommitted
feat: simplify visibility flags to --show-in-progress/--show-all
Replace --show-merged and --show-closed with two simpler flags: - --show-in-progress (default): only draft/open PRs - --show-all: show everything including merged and closed Update hidden PR summary to include worktree counts per state: Hidden: 4 (3 wt) merged, 4 closed. Co-Authored-By: Claude Code (/Users/nathan.heaps/src/stainless-api/stainless) <noreply@anthropic.com>
1 parent c4c9c6e commit 7dd314f

1 file changed

Lines changed: 40 additions & 30 deletions

File tree

bin/gs-stack-status

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ WATCH_INTERVAL=10
3333
TRUNCATE_BRANCH=35 # Default: truncate branch names to 35 chars
3434
TRUNCATE_PR_TITLE=0 # Default: no PR title truncation (0 = disabled)
3535
ONLY_REQUIRED_CI=1 # Default: CI status only reflects required checks
36-
SHOW_MERGED=0 # Default: hide merged PRs
37-
SHOW_CLOSED=0 # Default: hide closed PRs
36+
SHOW_ALL=0 # Default: --show-in-progress (hide merged/closed PRs)
3837

3938
while [[ $# -gt 0 ]]; do
4039
case "$1" in
@@ -99,12 +98,12 @@ while [[ $# -gt 0 ]]; do
9998
ONLY_REQUIRED_CI=0
10099
shift
101100
;;
102-
--show-merged)
103-
SHOW_MERGED=1
101+
--show-all)
102+
SHOW_ALL=1
104103
shift
105104
;;
106-
--show-closed)
107-
SHOW_CLOSED=1
105+
--show-in-progress)
106+
SHOW_ALL=0
108107
shift
109108
;;
110109
--truncate-branch-length)
@@ -140,8 +139,8 @@ while [[ $# -gt 0 ]]; do
140139
echo " --watch [SECS] Refresh in-place every SECS seconds (default: 10)"
141140
echo " --only-required-ci CI status reflects only required checks (default)"
142141
echo " --no-only-required-ci CI status reflects all checks"
143-
echo " --show-merged Show merged PRs (default: hidden)"
144-
echo " --show-closed Show closed PRs (default: hidden)"
142+
echo " --show-in-progress Show only draft/open PRs (default)"
143+
echo " --show-all Show all PRs including merged and closed"
145144
echo " --truncate-branch-length N Truncate branch names to N chars (default: 35)"
146145
echo " --truncate-pr-title N Truncate PR titles to N chars (default: no limit)"
147146
echo " -h, --help Show this help message"
@@ -526,33 +525,45 @@ while IFS= read -r wt_line; do
526525
done < <(git worktree list --porcelain 2>/dev/null)
527526

528527
# ---------------------------------------------------------------------------
529-
# Count hidden merged/closed PRs for summary line
528+
# Count hidden merged/closed PRs (with worktree counts) for summary line
530529
# ---------------------------------------------------------------------------
531530
hidden_merged=0
531+
hidden_merged_wt=0
532532
hidden_closed=0
533-
for branch in "${!pr_state[@]}"; do
534-
case "${pr_state[$branch]}" in
535-
MERGED) [[ "$SHOW_MERGED" -eq 0 ]] && ((hidden_merged++)) || true ;;
536-
CLOSED) [[ "$SHOW_CLOSED" -eq 0 ]] && ((hidden_closed++)) || true ;;
537-
esac
538-
done
533+
hidden_closed_wt=0
534+
if [[ "$SHOW_ALL" -eq 0 ]]; then
535+
for branch in "${!pr_state[@]}"; do
536+
case "${pr_state[$branch]}" in
537+
MERGED)
538+
((hidden_merged++)) || true
539+
[[ -n "${worktree_branches[$branch]+_}" ]] && ((hidden_merged_wt++)) || true
540+
;;
541+
CLOSED)
542+
((hidden_closed++)) || true
543+
[[ -n "${worktree_branches[$branch]+_}" ]] && ((hidden_closed_wt++)) || true
544+
;;
545+
esac
546+
done
547+
fi
539548

540549
# Print hidden PR summary line (called at end of each output format)
541550
print_hidden_summary() {
542551
if (( hidden_merged > 0 || hidden_closed > 0 )); then
543-
local summary="" flags=""
552+
local parts=""
544553
if (( hidden_merged > 0 )); then
545-
summary="${hidden_merged} merged"
546-
flags="--show-merged"
554+
parts="${hidden_merged}"
555+
(( hidden_merged_wt > 0 )) && parts="${parts} (${hidden_merged_wt} wt)"
556+
parts="${parts} merged"
547557
fi
548558
if (( hidden_closed > 0 )); then
549-
[[ -n "$summary" ]] && summary="${summary}, "
550-
summary="${summary}${hidden_closed} closed"
551-
[[ -n "$flags" ]] && flags="${flags}, "
552-
flags="${flags}--show-closed"
559+
[[ -n "$parts" ]] && parts="${parts}, "
560+
parts="${parts}${hidden_closed}"
561+
(( hidden_closed_wt > 0 )) && parts="${parts} (${hidden_closed_wt} wt)"
562+
parts="${parts} closed"
553563
fi
554564
echo ""
555-
echo " ${summary} hidden — use ${flags} to display"
565+
echo " Hidden: ${parts}."
566+
echo " Use --show-all to show all tracked branches regardless of state (default: --show-in-progress)"
556567
fi
557568
}
558569

@@ -578,13 +589,12 @@ branch_passes_filter() {
578589
return 0
579590
fi
580591

581-
# Filter merged/closed PRs unless --show-merged / --show-closed
582-
local state="${pr_state[$branch]:-}"
583-
if [[ "$state" == "MERGED" && "$SHOW_MERGED" -eq 0 ]]; then
584-
return 1
585-
fi
586-
if [[ "$state" == "CLOSED" && "$SHOW_CLOSED" -eq 0 ]]; then
587-
return 1
592+
# Filter merged/closed PRs unless --show-all
593+
if [[ "$SHOW_ALL" -eq 0 ]]; then
594+
local state="${pr_state[$branch]:-}"
595+
if [[ "$state" == "MERGED" || "$state" == "CLOSED" ]]; then
596+
return 1
597+
fi
588598
fi
589599

590600
# No other filters active — show everything

0 commit comments

Comments
 (0)