Skip to content

Share the formatter git-hooks' staged_gone check through check-lib.sh (part 1 of 2) #15627

Description

@kyle-sexton

Agent Brief

Type: Task
Summary: Move the staged_gone check that seven formatter git-hooks repeat into the canonical lib/git-hooks/check-lib.sh as checks_staged_gone, and switch the four actionlint, bash-format, biome-format and go-format hooks to it; part 2 switches the other three (part of restructuring pass #14381).

Current behavior:
Seven hooks define the same 4-line staged_gone <path> under the same 2-line comment: 0 at pre-commit when the path is gone from the work tree and the index holds it as a regular file. Each calls it once:

  • plugins/actionlint/git-hooks/actionlint-check.sh:38-43, called at :54
  • plugins/bash-format/git-hooks/shell-check.sh:56-61, called at :73
  • plugins/biome-format/git-hooks/biome-check.sh:66-71, called at :92
  • plugins/go-format/git-hooks/goimports-format.sh:72-77, called at :90
  • plugins/markdown-format/git-hooks/markdown-check.sh:72-77, plugins/powershell-format/git-hooks/powershell-check.sh:76-81 and plugins/ruff-format/git-hooks/ruff-check.sh:83-88 (part 2)

Every hook already sources check-lib.sh, from beside it or from ../lib/git-hooks/ (actionlint-check.sh:24-32), and staged_gone reads CHECKS_MODE, which that library sets (lib/git-hooks/check-lib.sh:143-150). The library already holds the sibling test checks_partly_staged (:544-554), listed in its function index (:50). The installer writes check-lib.sh beside each installed hook in a directory per plugin (lib/git-hooks/install.mjs:990-994,1051), so an installed hook and its library come from the same release.

Desired behavior:

  • lib/git-hooks/check-lib.sh defines checks_staged_gone <path> with the same body, beside checks_partly_staged, and its function index names it beside checks_partly_staged.
  • scripts/sync-shared-copies.sh regenerates the ten plugin copies of check-lib.sh (scripts/shared-copies.txt:624-633).
  • The four hooks above delete their comment and definition and call checks_staged_gone.
  • The three hooks of part 2 keep their own staged_gone until part 2; the new name does not collide with it.

Files:

  • lib/git-hooks/check-lib.sh
  • plugins/actionlint/git-hooks/actionlint-check.sh
  • plugins/bash-format/git-hooks/shell-check.sh
  • plugins/biome-format/git-hooks/biome-check.sh
  • plugins/go-format/git-hooks/goimports-format.sh
  • plugins/<plugin>/lib/git-hooks/check-lib.sh (generated) for typos-format, ruff-format, bash-format, biome-format, go-format, markdown-format, powershell-format, actionlint, guardrails and instruction-placement
  • a new patch fragment in .changes/<plugin>/ for each of those ten plugins: ### Changed, "Internal restructuring, no behavior change."

Key interfaces:

  • Each hook's arguments, output, exit codes and messages: unchanged.
  • No test names staged_gone; lib/git-hooks/check-lib.test.sh:72-77 tests checks_partly_staged by name, and no test pins the library's function list.

Acceptance criteria:

  • checks_staged_gone is defined once, in lib/git-hooks/check-lib.sh, and the four hooks call it with no local copy.
  • Behavior is unchanged: the same outputs, exit codes and printed results for the same inputs.
  • The diff edits only the listed files and the lines of a test that assert on them when the change breaks that assertion.
  • The pull request stays within 400 changed lines, not counting regenerated copies, and 15 hand-edited files.
  • scripts/sync-shared-copies.sh --check and scripts/sync-shared-copies.sh --check-bump origin/main pass.
  • lib/git-hooks/check-lib.test.sh, actionlint-check.test.sh, shell-check.test.sh, biome-check.test.sh and goimports-format.test.sh pass.
  • ci-status is green.

Out of scope:

  • The markdown-format, powershell-format and ruff-format hooks (part 2), each hook's batch loop, other duplication, eval cases, fixtures, and skill and agent text.

Activity

  1. added theissue type on Nov 12, 2026
  2. added
    status: ready
    on Nov 12, 2026
  3. removed
    status: ready
    on Nov 12, 2026
  4. melodic-automation-lanes commented on Nov 12, 2026

    @melodic-automation-lanes
    Contributor

    {"v":1,"actor_id":337595936,"title_sha256":"65657c75d1f60c13715603c682f71a7562d5da16bb9844f55a487cc3a9494fd7","body_sha256":"85de10906b1eaeb706b700be8f50b219573a8e86da7f699c285a0f6b1b7ddf1e"}

  5. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor
    No description provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Work status

    needs-triage

    Priority

    low

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions