Add --staged for pre-commit hooks: --changed also scans unstaged edits and untracked files
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 62/100
Rechercherichtung
Start at internal/gitx/gitx.go around ChangedUncommitted (lines 292-310) to see how git diff HEAD and ls-files --others feed the file list, then follow that list into internal/engine/diffscan.go (lines 38-39) where texts enter walk.Texts. Wire the new --staged flag in internal/cli/scan.go:32, mutually exclusive with --since and --changed, listing with git diff --cached --name-only -z --diff-filter=ACMR. Done when go test ./internal/gitx ./internal/engine ./internal/cli passes, a staged-only scan ignores untracked and unstaged files, docs/ci.md:141-146 shows --staged, and a .pre-commit-hooks.yaml with id: spackle exists.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
docs/ci.md documents spackle scan . --changed as the pre-commit hook, but --changed scans staged edits, unstaged edits and every untracked, non-ignored file, all read from the working tree. A pre-commit hook should judge what is being committed. Add a --staged mode, and ship a hook manifest for the pre-commit framework.
Where
internal/gitx/gitx.go:292-310(ChangedUncommitted:git diff HEADplusls-files --others)internal/engine/diffscan.go:38-39docs/ci.md:141-146(the documented hook)internal/cli/scan.go:32
Impact
- An untracked scratch file that will not be committed can block the commit.
- With a partial commit (
git add -p), an unstaged edit that is not in the commit can block it. - A risky line that is staged and then fixed only in the working tree passes the hook, although the staged version is what lands.
Teams using the pre-commit framework or lefthook cannot add Spackle with a repo:/rev: entry: there is no .pre-commit-hooks.yaml, so every clone needs a hand-written hook.
Steps to reproduce
- Create an untracked
scratch.pycontainingcursor.execute(f"... {x}"). - Stage an unrelated, clean change.
- The documented hook exits 1 and blocks a commit that does not contain the flaw.
Suggested fix
- Add
--staged, mutually exclusive with--sinceand--changed. Listgit diff --cached --name-only -z --diff-filter=ACMRand read each listed file's staged blob (git show :<path>through gitx with the same no-textconv guards) into the sharedwalk.Textsin place of the working-tree text. - A cheaper first step is staged names with working-tree content, plus a run note saying so.
- Trade-off: external scanners read the tree themselves, so a faithful index read needs a temporary checkout of the index (
git checkout-index --prefix=), or this mode is limited to the built-in seeders. - Change the
docs/ci.mdhook to--staged. - Add
.pre-commit-hooks.yamlwith anid: spacklehook (entry: spackle scan . --staged --offline --fail-on high,pass_filenames: false,always_run: true) and document it.
Acceptance criteria
-
--stagedreports leads only in staged files, using their staged content (or says in a note that it reads the working tree). - Untracked files and unstaged edits do not affect a
--stagedscan. - A
.pre-commit-hooks.yamllets pre-commit users add Spackle withrepo:andrev:.
Getting started
- Relevant files:
internal/gitx/gitx.go,internal/engine/diffscan.go,internal/cli/scan.go,docs/ci.md - How to run tests:
go test ./internal/gitx ./internal/engine ./internal/cli
Filed by repo-audit/full-audit at fffef43. Severity: medium. Effort: M. audit-key: enhancement|internal/gitx/gitx.go|ChangedUncommitted
- Vorherrschende Sprache
- Go
- Sterne
- 0
- Forks
- 1
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TMHSDigital/Spackle
-
enhancement good first issue severity: low
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 72/100
TMHSDigital/Spackle#139 ·
-
enhancement good first issue severity: low
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
TMHSDigital/Spackle#138 ·
-
documentation good first issue severity: low
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
TMHSDigital/Spackle#135 ·
-
bug good first issue severity: low
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
TMHSDigital/Spackle#131 ·
-
runs and runs compare print target text without the control-character cleaning the reports useOffenbug good first issue severity: low
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
TMHSDigital/Spackle#129 ·
Alle Issues in TMHSDigital/Spackle
Ähnliche Issues
-
bug raised-by:reviewer
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
medici-finance/assay#7655 ·
Maintainer antworten meist innerhalb von 1 Tag
-
helm chart: make DaemonSet pod affinity configurable via values.yamlEvtl. vergeben @Young-Zen hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
flannel-io/flannel#2632 ·
Maintainer antworten meist innerhalb von 6 Tagen
-
go-vulnerability security-scan
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
teslashibe/agent-go#36 ·
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
nwverse/persona#15194 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug flaky-test
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
rosskukulinski/tailworks#411 ·
Maintainer antworten meist innerhalb von 1 Tag