Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.13.0] - 2026-08-29

### Added

- **`gh-traffic.sh --summary`** shows only the cross-repo rollup table added
in 5.12.0 and skips per-repo detail entirely — for scanning traffic across
many repos without the daily-breakdown noise. Works with any number of
repos, including one. If `--referrers` came along (directly or via
`--all`), it's dropped rather than fetched: the summary has no column for
it, and `--summary` means per-repo detail — where referrers would
otherwise show — isn't printed at all. Passing `--referrers` with no
views or clones section active errors out instead, since the summary
would then have nothing to put in it.

## [5.12.0] - 2026-08-29

### Added
Expand Down
7 changes: 7 additions & 0 deletions go/internal/catalog/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@
"required": false,
"description": "Suppress header rows in table output",
"raw": "--quiet optional {} Suppress header rows in table output"
},
{
"name": "--summary",
"required_raw": "optional",
"required": false,
"description": "Show only the cross-repo summary table, skipping per-repo detail",
"raw": "--summary optional {} Show only the cross-repo summary table, skipping per-repo detail"
}
],
"examples": [
Expand Down
64 changes: 47 additions & 17 deletions scripts/git/gh-traffic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# @flag --days optional {14} Limit the day-series sections to the last N days (max: 14)
# @flag --json optional {} Output raw JSON instead of formatted tables
# @flag --quiet optional {} Suppress header rows in table output
# @flag --summary optional {} Show only the cross-repo summary table, skipping per-repo detail
# @example wp-ops gh-traffic imagewize/nynaeve --quiet
# @example wp-ops gh-traffic imagewize/nynaeve imagewize/wp-ops --all

Expand All @@ -27,6 +28,7 @@ set -euo pipefail
# Default values
JSON_OUTPUT=false
QUIET=false
SUMMARY_ONLY=false
DAYS=14
SHOW_VIEWS=false
SHOW_CLONES=false
Expand All @@ -53,6 +55,7 @@ Options:
-d, --days N Limit day-series sections to the last N days (default: 14, max: 14)
-j, --json Output raw JSON instead of formatted tables
-q, --quiet Suppress header rows in table output
-s, --summary Show only the cross-repo summary table, skipping per-repo detail

Arguments:
owner/repo GitHub repository in format owner/repo (required, repeatable)
Expand All @@ -66,6 +69,10 @@ Sections:
if views weren't requested. It's skipped for a single repo (redundant with
the detail table) and for a referrers-only run (nothing numeric to sort).

--summary shows only that rollup, for any number of repos, and drops
--referrers if it was also given (or implied by --all) — the summary has
no column for it and per-repo detail isn't printed to show it elsewhere.

Examples:
# Views only (default)
./scripts/git/gh-traffic.sh imagewize/nynaeve
Expand All @@ -79,6 +86,9 @@ Examples:
# Machine-readable output
./scripts/git/gh-traffic.sh --all --json imagewize/nynaeve

# Just the rollup across many repos, views and clones
./scripts/git/gh-traffic.sh --all --summary imagewize/nynaeve imagewize/wp-ops imagewize/aludra

Requirements:
- GitHub CLI (gh) installed and authenticated
- jq for JSON processing
Expand Down Expand Up @@ -146,6 +156,10 @@ while [[ $# -gt 0 ]]; do
QUIET=true
shift
;;
-s|--summary)
SUMMARY_ONLY=true
shift
;;
-*)
echo "Error: Unknown option $1" >&2
echo "Use --help for usage information" >&2
Expand All @@ -164,6 +178,18 @@ if [[ "$SHOW_CLONES" = false && "$SHOW_REFERRERS" = false ]]; then
SHOW_VIEWS=true
fi

# --summary prints only the rollup, so it needs at least one numeric section
# to put in it — referrers has none. Drop referrers silently rather than
# erroring when it came along via --all: that's asking for "totals only",
# not specifically asking to see referrers nowhere.
if [[ "$SUMMARY_ONLY" = true ]]; then
if [[ "$SHOW_VIEWS" = false && "$SHOW_CLONES" = false ]]; then
echo "Error: --summary needs a views or clones section to summarize (referrers has no numeric column) — drop --referrers or add --clones" >&2
exit 1
fi
SHOW_REFERRERS=false
fi

# Validate repository arguments
if [[ ${#REPOS[@]} -eq 0 ]]; then
echo "Error: At least one repository argument is required" >&2
Expand Down Expand Up @@ -453,27 +479,31 @@ for i in "${!REPOS[@]}"; do
fi
done

# The summary only means anything with more than one repo, and only when it
# has a numeric column to sort — a referrers-only run has neither.
if [[ ${#REPOS[@]} -gt 1 && ( "$SHOW_VIEWS" = true || "$SHOW_CLONES" = true ) ]]; then
# --summary always gets the rollup, any number of repos. Otherwise it only
# means anything with more than one repo, and only when it has a numeric
# column to sort — a referrers-only run has neither.
if [[ "$SUMMARY_ONLY" = true ]] || \
[[ ${#REPOS[@]} -gt 1 && ( "$SHOW_VIEWS" = true || "$SHOW_CLONES" = true ) ]]; then
print_summary
fi

for i in "${!REPOS[@]}"; do
repo="${REPOS[$i]}"
echo "=== ${repo} ==="
echo
if [[ "$SUMMARY_ONLY" = false ]]; then
for i in "${!REPOS[@]}"; do
repo="${REPOS[$i]}"
echo "=== ${repo} ==="
echo

if [[ "$SHOW_VIEWS" = true && "${VIEWS_OK[$i]}" = true ]]; then
print_series "views" "Views" "${VIEWS_PAYLOAD[$i]}"
fi
if [[ "$SHOW_CLONES" = true && "${CLONES_OK[$i]}" = true ]]; then
print_series "clones" "Clones" "${CLONES_PAYLOAD[$i]}"
fi
if [[ "$SHOW_REFERRERS" = true && "${REFERRERS_OK[$i]}" = true ]]; then
print_referrers "${REFERRERS_PAYLOAD[$i]}"
fi
done
if [[ "$SHOW_VIEWS" = true && "${VIEWS_OK[$i]}" = true ]]; then
print_series "views" "Views" "${VIEWS_PAYLOAD[$i]}"
fi
if [[ "$SHOW_CLONES" = true && "${CLONES_OK[$i]}" = true ]]; then
print_series "clones" "Clones" "${CLONES_PAYLOAD[$i]}"
fi
if [[ "$SHOW_REFERRERS" = true && "${REFERRERS_OK[$i]}" = true ]]; then
print_referrers "${REFERRERS_PAYLOAD[$i]}"
fi
done
fi

[[ "$FAILED" = true ]] && exit 1
exit 0