--changed refuses a repository with no commit and counts .spackle state files as changed
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 70/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- git, go
研究方向
Start with ChangedUncommitted in internal/gitx/gitx.go and the HasTracked precheck and error wording in changedSince in internal/engine/diffscan.go; reproduce both cases in a fresh git init and in a repo with one commit. The state directory exclusion can follow the existing IsCleanExcept pathspec approach in internal/mapper/mapper.go. Done means go test ./internal/gitx ./internal/engine passes with the new TestChangedUncommitted cases, and --changed works before the first commit without counting .spackle files.
由索引模型根據 Issue 內容生成。
描述
Summary
The file listing behind --changed has two bugs, and its edge cases have no direct test. It refuses a repository that has no commit yet, and it counts every file of the untracked .spackle/ state directory as a changed file.
Where
internal/gitx/gitx.go:294-309(ChangedUncommitted)internal/engine/diffscan.go:28-49(changedSince:HasTrackedprecheck, error wording)internal/engine/diffscan.go:63-71(keepChangedprintslen(changed))internal/mapper/mapper.go:103-111(the mapper already excludes the state dir withIsCleanExcept)
Details
func ChangedUncommitted(ctx context.Context, dir string) ([]string, error) {
files, err := changedFiles(ctx, dir, "HEAD")
...
out, err := run(ctx, dir, "ls-files", "-z", "--others", "--exclude-standard")
- Before the first commit. HEAD does not resolve, so
git diff ... HEADfails withfatal: bad revision 'HEAD'and the scan is refused:run refused: --changed: git could not list the changes against HEAD, exit 2. In a freshgit initwith nothing staged, theHasTrackedprecheck refuses earlier with "has no tracked files", although every file is uncommitted work. - State directory counted.
ls-files --others --exclude-standardlists everything under the defaultstate_dir = ".spackle", which sits inside the target and is untracked and not ignored. Ledgers, reports, evidence, map cache files and clones all count as changed files. The lead filter is unaffected (the walk never lists.spackle/), but the note shows a wrong count that grows with every stored run.
Impact
--changed is documented as "a scan before you commit", but it cannot be used for a project's first commit, a common pre-commit-hook case. After the first scan, every --changed run reports an inflated "N changed files" in the terminal, the ledger and every report.
Steps to reproduce
git init x && cd x, createmain.go,git add main.go, thenspackle scan --changed --provider "" .: refused, exit 2.- In a repository with one commit:
spackle scan --provider "" ., editmain.go, thenspackle scan --changed --provider "" .. The note says "9 changed files" whilegit status --porcelainshows onlyM main.goand?? .spackle/.
Suggested fix
- When
git rev-parse --verify -q HEADfails, listgit ls-files -z(the index) plus the untracked files instead of diffing against HEAD. InchangedSince, skip theHasTrackedprecheck for--changedand keepErrNotRepoas the only refusal. - Exclude the state directory from both git calls with a pathspec, as
IsCleanExceptdoes (-- . ":(exclude).spackle", using the configured state dir name), or drop entries under it before returning.
Acceptance criteria
-
--changedworks before the first commit and treats staged and untracked files as changed. - Files under the state directory never appear in the changed set or its count.
-
TestChangedUncommittedininternal/gitxcovers: staged-only edit, unstaged edit, deleted file (not listed),git mvrename (new name only), untracked vs ignored, a subdirectory target (paths relative to it), names with spaces and non-ASCII, a clean tree, no commits, and the state directory. - A CLI test passes
--changedthrough to the engine, and--changed --since HEADexits with a usage error.
Getting started
- Relevant files:
internal/gitx/gitx.go,internal/gitx/gitx_test.go,internal/engine/diffscan.go - How to run tests:
go test ./internal/gitx ./internal/engine
Filed by repo-audit/full-audit at fffef43. Severity: low. Effort: S. audit-key: bug|internal/gitx/gitx.go|ChangedUncommitted
- 主要語言
- Go
- 星號
- 0
- 分支
- 1
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TMHSDigital/Spackle 的其他 Issue
-
enhancement good first issue severity: low
難度 2/5 半天 新手友好度 72/100
TMHSDigital/Spackle#139 ·
-
enhancement good first issue severity: low
難度 2/5 1-3 小時 新手友好度 72/100
TMHSDigital/Spackle#138 ·
-
documentation good first issue severity: low
難度 2/5 1-3 小時 新手友好度 78/100
TMHSDigital/Spackle#135 ·
-
bug good first issue severity: low
難度 2/5 1-3 小時 新手友好度 72/100
TMHSDigital/Spackle#131 ·
-
bug good first issue severity: low
難度 2/5 1-3 小時 新手友好度 78/100
TMHSDigital/Spackle#129 ·
查看 TMHSDigital/Spackle 的全部 Issue
相似的 Issue
-
bug raised-by:reviewer
難度 2/5 1-3 小時 新手友好度 66/100
medici-finance/assay#7655 ·
維護者通常 1 天內回覆
-
helm chart: make DaemonSet pod affinity configurable via values.yaml可能已有人在做 @Young-Zen 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
flannel-io/flannel#2632 ·
維護者通常 6 天內回覆
-
go-vulnerability security-scan
難度 1/5 1 小時以內 新手友好度 72/100
teslashibe/agent-go#36 ·
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
nwverse/persona#15194 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug flaky-test
難度 2/5 1-3 小時 新手友好度 78/100
rosskukulinski/tailworks#411 ·
維護者通常 1 天內回覆