Skip to content

refactor(repo-hygiene): simplify the clean git branch, prune and stash scripts - #15165

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14717-42884738174-1
Nov 10, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14717-42884738174-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14717

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified the four listed repo-hygiene clean scripts without changing their output, exit codes, written files or flags. git-branch-audit.sh now sets each tier/reason/pr_line verdict in one assignment (the style its remote_audit already used), feeds the gone/merged branch sets straight from process substitution instead of through two otherwise-unused variables, drops a no-op : arm from the upstream-track parse, and uses plain if blocks in place of &amp;&amp; { ...; }. git-branch-delete.sh collects the arguments after -- in one append, reduces delete_mode to one condition, and drops an empty : branch from the landed-proof re-check. git-prune.sh flattens its loop with continue, and git-stash-audit.sh checks for origin/<default> once instead of once per stash, puts the two duplicated stash-stat pipelines in a stash_stat helper, and uses rev-list -n 1 in place of rev-list | head -1. A sed-to-bash-regex rewrite of the stash subject parse was reverted after review showed it changes output on BSD/macOS sed and on invalid UTF-8 subjects.

Not verified

  • The repo-hygiene clean script test suites (git-branch-audit.test.sh, git-branch-delete.test.sh, git-prune.test.sh, git-stash-audit.test.sh) were not executed here: this lane's Bash runs only the named wrappers; left to the PR's CI
  • ci-status green is a PR check, left to the PR's CI
  • tidy passes 4 and 5 (docs-hygiene writing rules, ai-slop fix) skipped on the changelog fragment: its only line is the exact text the issue's acceptance criteria require, so no rewrite is allowed
  • cant-fail-scan not applied: it scans test files and this change touches none
  • Not simplified, to keep behavior byte-identical: git-stash-audit.sh's COMMON_DIR lookup was left as is because clean_git_common_dir resolves symlinks (pwd -P) and would change the printed StashStore path; the stash subject sed parse was kept for portability (see verification)

Fix

  • plugins/repo-hygiene/skills/clean/scripts/git-branch-audit.sh: one-line tier/reason assignments in classify_branch, process substitution for GONE_SET/MERGED_SET (GONE_BRANCHES/MERGED_BRANCHES variables and a no-op || true removed), : arm removed from bulk_facts' track parse, two `&& {…
  • plugins/repo-hygiene/skills/clean/scripts/git-branch-delete.sh: -- argument loop replaced by BRANCHES+=("$"); break, delete_mode reduced to one condition, redundant ${var:-} defaults on read-assigned vars dropped, empty : then-branch in the live landed-proof re-check replaced by a negated…
  • plugins/repo-hygiene/skills/clean/scripts/git-prune.sh: loop flattened with continue, if ! cmd; then printf; fi written as cmd || printf
  • plugins/repo-hygiene/skills/clean/scripts/git-stash-audit.sh: origin/<default> existence checked once before the loop (ORIGIN_DEFAULT), stash_stat helper for the two diffstat pipelines, rev-list -n 1 instead of rev-list | head -1
  • .changes/repo-hygiene/work-resolve-issue-issue-14717-42884738174-1-0043765e.md: patch fragment from new-changelog-fragment, body ### Changed / - Internal simplification, no behavior change.

Verification

The runner ran each check from the base copy against b7a7613:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 9 fragments valid (run before and after the review fix)
  • check-changed-skills: CHECK-SKILL clean PASS, 0 errors, 4 pre-existing size/Gotchas warnings unrelated to the scripts
  • check-affected: 13 passed, 6 skipped over 5 changed files (run before and after the review fix)
  • fresh-context review subagent over the whole diff: found the stash subject sed-to-regex rewrite changes output on BSD/macOS sed (GNU \| alternation) and on invalid UTF-8 subjects under a UTF-8 locale; reverted to the original sed; judged every other hunk equivalent with reasons
  • tidy-diff over the 38 changed hunks: passes 1-3 found nothing further to edit; passes 4-5 skipped (see not_done)
  • diff scope: only the four listed files and one changelog fragment; no listed file renamed, moved or deleted; about 120 changed lines
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42884738174

Left out: the items under Not verified.

Related

#14717

Merge-Risk: max=MEDIUM demote=false head=b7a76133b396a05f5b5afea20832413354d9ce8f rubric=8.3.5 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed b7a76133b396a05f5b5afea20832413354d9ce8f: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15165 (head b7a7613)

I found no security issues.

Scope. I read every hunk of all 5 files in the diff: one changelog fragment and four repo-hygiene clean scripts (git-branch-audit.sh, git-branch-delete.sh, git-prune.sh, git-stash-audit.sh). None of them matches a trusted path. The diff touches no plugin manifest, no workflow, no trust control and no instruction surface.

What I checked. Branch deletion is destructive, so I checked that each refactor keeps the safety logic it touches:

  • delete_mode. The old case and the new one-line condition both give safe only for tier SAFE with a PR field that does not match PR_MERGED_RE. Every other case still gives force. Same result.
  • Landed-proof re-check. if A && B; then :; else refuse became if ! { A && B; }; then refuse. Same result: the live loss check still refuses unless a captured LIKELY-SAFE Landed proof still holds.
  • bulk_facts track parse. An empty track still matches no regex and skips return 1. An unrecognised non-empty track still returns 1. Same result.
  • -- argument handling. BRANCHES+=("$@"); break leaves the outer while loop (git-branch-delete.sh line 100). Nothing after the loop reads $@ or $#, so every branch name still passes the per-branch checks from line 290 on.
  • CAP_TIER / CAP_LANDED without the :- default. read assigns every variable it names, even an empty one, so set -u (line 59) is not tripped.
  • GONE/MERGED sets now filled by process substitution. None of these scripts uses set -e (they use set -u or set -uo pipefail), so dropping || true changes no exit behavior.
  • git-prune.sh. The continue flattening is the same logic. The eval "$op" was already there; it runs only the script's own GIT_PRUNE_OPS, and this diff does not change it.
  • git-stash-audit.sh. The origin/<default> check runs once instead of once per stash, and rev-list -n 1 replaces rev-list | head -1. Same advisory output.

No step needed a person's decision, so I set no hold.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed b7a76133b396a05f5b5afea20832413354d9ce8f: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15165 (refactor(repo-hygiene): simplify the clean git branch, prune and stash scripts)

No findings. I read every hunk in all 5 changed files and checked each rewrite against the base behavior. I also read the unchanged code around them: the shell options in each script header, the arg-parsing loop in git-branch-delete.sh, and the set-up of the stash loop in git-stash-audit.sh. None of the files is on a trusted path.

What I checked

  • git-branch-audit.sh (runs with set -u only, no -e or pipefail):
    • Replacing [[ … ]] && { …; } with if … fi changes no output or exit status, both at top level and inside the while loop.
    • GONE_SET/MERGED_SET now read from process substitution instead of a here-string. Empty input still adds nothing, because the [[ -n "$line" ]] guard skips empty lines. Dropping || true is a no-op, since nothing reads the exit status of a process substitution.
    • In bulk_facts, removing the : arm and moving the empty-$track test to elif [[ -n "$track" ]]; then return 1 gives the same result for every input: empty, ahead, behind, ahead+behind and malformed.
    • The one-line tier=… reason=… pr_line=… assignments are all plain assignments with no command substitution, so the values and exit statuses are the same.
  • git-branch-delete.sh (set -uo pipefail):
    • For --, BRANCHES+=("$@"); break collects the same arguments as the old loop, and nothing after the parse loop reads $@ or $#.
    • delete_mode keeps the same truth table: SAFE without a merged PR gives safe, everything else gives force.
    • The negated if ! { … && clean_landed_proof …; } is the same as the old empty : then-branch.
    • ${c_tier:-} → $c_tier is safe under set -u, because read sets every named variable even when fields are missing.
  • git-prune.sh: Flattening the loop with continue and switching to cmd || printf keep the same printed lines and the same order of commands.
  • git-stash-audit.sh:
    • ORIGIN_DEFAULT is computed after REPO_ROOT and DEFAULT_BRANCH are set, and nothing in the loop changes remote refs. The condition chain is evaluated in the same order as before.
    • rev-list -n 1 gives the same empty or non-empty answer as rev-list | head -1.
    • The stash_stat helper runs the same pipeline as the two inline copies did.

Closing issue #14717 acceptance criteria

  • Behavior unchanged: met as far as I can tell by reading the code. I did not run the four *.test.sh suites; the PR says they were left to CI (author-claimed, unverified).
  • Diff edits only the listed files plus changelog fragments: met (4 listed scripts plus 1 fragment).
  • At most 400 changed lines and 15 hand-edited files: met.
  • ci-status is green: I could not check this from here; it is left to the PR's checks.
  • Fragment with bump: patch, ### Changed, and "Internal simplification, no behavior change.": met.

No plugin manifest was changed, so no manifest items apply. I found no embedded instructions in the PR context.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head b7a76133b396a05f5b5afea20832413354d9ce8f, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for b7a7613

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15165-b7a76133b396a05f5b5afea20832413354d9ce8f, expires on 2026-12-10.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit f2435c3 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14717-42884738174-1 branch November 10, 2026 20:57
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 5, survived 1, timeout 0, no coverage 0, invalid 0, not run 1.
Covered-code score 83%; mutation score 83%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/repo-hygiene/skills/clean/scripts/git-branch-audit.sh 2 0 0 0 0 0
plugins/repo-hygiene/skills/clean/scripts/git-branch-delete.sh 2 1 0 0 0 0
plugins/repo-hygiene/skills/clean/scripts/git-prune.sh 0 0 0 0 0 1
plugins/repo-hygiene/skills/clean/scripts/git-stash-audit.sh 1 0 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/repo-hygiene/skills/clean/scripts/git-branch-delete.sh:132 SBR productive input-gap

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit f2435c34dba32b887844ee48d9723f236288e2bf; later checks count it verified from this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the clean repo-hygiene plugin code (2 of 5)

0 participants