Skip to content

Pre-commit hook doesn't flag deleted build assets (js/css) #132

Description

@moodyjmz

TL;DR: .githooks/pre-commit only checks staged files with --diff-filter=ACM (Added/Copied/Modified), never D (Deleted). Before #129, local builds never deleted anything under js//css/ (fixed js/ filenames, css/ only grew), so the gap was invisible. After #129 (which empties css/ before each build to stop stale hashed chunks from accumulating), a local npm run build && git commit -am ... will silently commit CSS deletions — the hook stays quiet, and CI's npm-build "check build changes" job even goes green on that commit since the output matches.

Detail
  • .githooks/pre-commit line ~14: git diff --cached --name-only --diff-filter=ACM -- js/ css/ (or equivalent) never surfaces deleted paths, so the hook's "you're about to commit generated build assets" guard silently misses deletions.
  • This repo's intended flow (per AGENTS.md) is: contributors run npm run build locally to test, then git restore --staged js css before committing — the hook is meant as a backstop for anyone who forgets. That backstop has a hole specifically for deletions.
  • Suggested fix: include D in the --diff-filter (e.g. --diff-filter=ACMD), so a staged deletion under js//css/ trips the same warning as an addition/modification.
  • Found during review of build: remove outdated CSS files when building #129 (build: remove outdated CSS files when building).

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending approval or rejectionlowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions