refactor: ponytail audit cleanup — plan_credits, _copilot_api, install-hooks, test boilerplate#43
Merged
Merged
Conversation
…nd test boilerplate
- Collapse plan_credits() from two identical case blocks (promo/standard)
into one case keyed by plan type with inline promo check — saves ~16 lines
- Inline gh_api --api-version 2026-03-10 at both call sites and delete the
_copilot_api() 2-line wrapper that only existed to fix that flag
- Source lib/github-common.sh in install-hooks.sh to reuse color vars
(RED/GREEN/YELLOW/NC) instead of redeclaring them; keep the [HOOKS]-labelled
print functions since they differ from the lib's [SUCCESS]/[WARNING]/[ERROR]
- Add _run_script() helper to test_script_validation.bats and replace all 59
single-line run bash -c invocations — removes the repeated
"export PATH='${MOCK_BIN}:${PATH}';" boilerplate from every test body
All 91 bats tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Four over-engineering removals from the ponytail audit:
1. Collapse
plan_credits()double case blockTwo identical
caseblocks (promo / standard) differing only in 4 values → one case with an inline promo check. Saves ~16 lines.2. Inline
_copilot_api()wrapperA 2-line function that just called
gh_apiwith--api-version 2026-03-10was called exactly twice. Inlined at both call sites, wrapper deleted.3. Source lib in
install-hooks.shDropped the redeclared
RED/GREEN/YELLOW/NCcolor vars — they're already inlib/github-common.sh. The[HOOKS]-labelled print functions are kept since their prefix differs from the lib's[SUCCESS]/[WARNING]/[ERROR].4.
_run_scripttest helperAdded a helper to
test_script_validation.batsand replaced all 59 single-linerun bash -c "export PATH='${MOCK_BIN}:${PATH}'; ..."invocations. The repeated PATH-prepend boilerplate is now in one place.Verification
All 91 bats tests pass.