ops: add weekly growth review scaffold#39
Conversation
| release_version="$(printf '%s' "${release_json}" | python3 -c 'import json,sys; data=json.load(sys.stdin); print(data.get("tagName",""))')" | ||
| fi | ||
| if [[ -z "${release_downloads}" ]]; then | ||
| release_downloads="$(printf '%s' "${release_json}" | python3 -c 'import json,sys; data=json.load(sys.stdin); print(sum(a.get("downloadCount",0) for a in data.get("assets",[])))')" |
There was a problem hiding this comment.
Undocumented
python3 dependency may cause unexpected exit
python3 is called inside the if gh ... block without a prior command -v python3 guard. With set -euo pipefail active, if python3 is absent (e.g. minimal CI, Alpine containers) the script exits with a cryptic "command not found" error instead of gracefully leaving the release fields empty. The usage block and --help output also don't mention this requirement.
Consider using gh's built-in --jq flag (no extra binary needed) or adding a guard similar to the gh check:
if [[ -z "${release_version}" ]]; then
release_version="$(gh release view --repo IntelIP/ProfitCtl --json tagName --jq '.tagName' 2>/dev/null || true)"
fi
if [[ -z "${release_downloads}" ]]; then
release_downloads="$(gh release view --repo IntelIP/ProfitCtl --json assets --jq '[.assets[].downloadCount] | add // 0' 2>/dev/null || true)"
fiPrompt To Fix With AI
This is a comment left during a code review.
Path: scripts/growth/scaffold-weekly-review.sh
Line: 91-94
Comment:
**Undocumented `python3` dependency may cause unexpected exit**
`python3` is called inside the `if gh ...` block without a prior `command -v python3` guard. With `set -euo pipefail` active, if `python3` is absent (e.g. minimal CI, Alpine containers) the script exits with a cryptic "command not found" error instead of gracefully leaving the release fields empty. The usage block and `--help` output also don't mention this requirement.
Consider using `gh`'s built-in `--jq` flag (no extra binary needed) or adding a guard similar to the `gh` check:
```bash
if [[ -z "${release_version}" ]]; then
release_version="$(gh release view --repo IntelIP/ProfitCtl --json tagName --jq '.tagName' 2>/dev/null || true)"
fi
if [[ -z "${release_downloads}" ]]; then
release_downloads="$(gh release view --repo IntelIP/ProfitCtl --json assets --jq '[.assets[].downloadCount] | add // 0' 2>/dev/null || true)"
fi
```
How can I resolve this? If you propose a fix, please make it concise.| --week-of) | ||
| week_of="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --owner) | ||
| owner="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --release-version) | ||
| release_version="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --release-downloads) | ||
| release_downloads="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --homebrew-installs) | ||
| homebrew_installs="${2:-}" | ||
| shift 2 | ||
| ;; | ||
| --output) | ||
| output_path="${2:-}" | ||
| shift 2 | ||
| ;; |
There was a problem hiding this comment.
shift 2 unguarded when option value is omitted
Every value-taking option (e.g. --week-of, --owner, --output) uses ${2:-} to silently accept an empty value, but still calls shift 2. If one of these flags is passed as the very last argument (no value following), $# is 1, shift 2 exits with a non-zero status, and set -e kills the script with no useful message.
A common guard pattern:
--week-of)
[[ $# -ge 2 ]] || { echo "Missing value for --week-of" >&2; exit 1; }
week_of="$2"
shift 2
;;Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/growth/scaffold-weekly-review.sh
Line: 38-61
Comment:
**`shift 2` unguarded when option value is omitted**
Every value-taking option (e.g. `--week-of`, `--owner`, `--output`) uses `${2:-}` to silently accept an empty value, but still calls `shift 2`. If one of these flags is passed as the very last argument (no value following), `$#` is 1, `shift 2` exits with a non-zero status, and `set -e` kills the script with no useful message.
A common guard pattern:
```bash
--week-of)
[[ $# -ge 2 ]] || { echo "Missing value for --week-of" >&2; exit 1; }
week_of="$2"
shift 2
;;
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
Testing
Greptile Summary
This PR adds
scripts/growth/scaffold-weekly-review.sh, a Bash script that generates a prefilled weekly-review Markdown file and a matching adoption-dashboard row, optionally pulling the latest release metadata from GitHub viagh release view. The three docs files (README.md,adoption-dashboard.md,weekly-review-template.md) are updated to reference the new script.Confidence Score: 5/5
Safe to merge; only P2 robustness suggestions remain.
All findings are P2 style/robustness improvements (undocumented python3 dependency, unguarded shift 2). The docs changes are clean and consistent. No logic errors, security issues, or broken behaviour on the happy path.
scripts/growth/scaffold-weekly-review.sh — the python3 guard and shift 2 guard are worth a quick fix before wider adoption.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A([scaffold-weekly-review.sh]) --> B[Parse CLI args] B --> C{output_path set?} C -- No --> D[Default: /tmp/profitctl-weekly-review-WEEK.md] C -- Yes --> E{File exists & no --force?} D --> E E -- Yes --> F[Exit 1: use --force] E -- No --> G{release_version or release_downloads missing?} G -- No --> K G -- Yes --> H{gh available?} H -- No --> K H -- Yes --> I[gh release view --json tagName,assets] I --> J[python3: parse tagName & downloadCount] J --> K[mkdir -p dirname output_path] K --> L[Write Markdown review scaffold] L --> M[Print dashboard row to stdout]Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "ops: add weekly growth review scaffold" | Re-trigger Greptile