Skip to content

test: add missing noprefix test for hunk show command#117

Merged
benvinegar merged 1 commit intomainfrom
test/add-show-noprefix-test
Mar 24, 2026
Merged

test: add missing noprefix test for hunk show command#117
benvinegar merged 1 commit intomainfrom
test/add-show-noprefix-test

Conversation

@benvinegar
Copy link
Member

Follow-up to #106 - adds the missing test coverage for `hunk show` with `diff.noprefix=true`.

This completes the test coverage for all git-backed commands that use `withNormalizedDiffPrefixes()`:

  • ✓ `hunk diff` (unstaged) with noprefix
  • ✓ `hunk diff --staged` with noprefix
  • ✓ `hunk stash show` with noprefix
  • ✓ `hunk diff` with mnemonicPrefix
  • ✓ `hunk show` with noprefix (this PR)

All 5 tests pass:
````
bun test test/loaders.test.ts -t "diff.noprefix is enabled|diff.mnemonicPrefix is enabled"
5 pass, 15 filtered out, 0 fail
````

Adds regression test for hunk show with diff.noprefix=true,
completing the test coverage for all git-backed commands that
use withNormalizedDiffPrefixes().
@greptile-apps
Copy link

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR adds a single integration test that fills the last gap in the withNormalizedDiffPrefixes() test matrix: verifying that hunk show correctly parses diff output even when diff.noprefix=true is set in the local git config. The new test follows the same structure as the three existing noprefix/mnemonicPrefix tests and slots in cleanly between the existing show tests.

  • New test "loads show output when diff.noprefix is enabled" creates a fresh temp repo, enables diff.noprefix locally, commits a change, then calls loadFromRepo with kind: "show" and asserts the parsed file path is correct.
  • The test exercises buildGitShowArgswithNormalizedDiffPrefixes, which injects -c diff.srcPrefix=a/ -c diff.dstPrefix=b/ to override any noprefix/mnemonicPrefix configuration before running git show.
  • No production code changes; all changes are confined to the test file.

Confidence Score: 5/5

  • This PR is safe to merge — it adds a single, self-contained test with no production code changes.
  • The change is a test-only addition that follows established patterns exactly. The test setup, execution, and assertion are consistent with the other noprefix tests in the file, and it correctly exercises the intended code path (buildGitShowArgs + withNormalizedDiffPrefixes).
  • No files require special attention.

Important Files Changed

Filename Overview
test/loaders.test.ts Adds a new integration test for hunk show with diff.noprefix=true, following established patterns. The test correctly configures a local git repo, sets diff.noprefix, commits a change, and asserts that loadFromRepo still resolves the file path — exercising withNormalizedDiffPrefixes in buildGitShowArgs.

Sequence Diagram

sequenceDiagram
    participant Test as Test (loaders.test.ts)
    participant Repo as Temp Git Repo
    participant Loader as loadFromRepo / loadAppBootstrap
    participant Git as git show

    Test->>Repo: git init + initial commit (alpha.ts v1)
    Test->>Repo: git config diff.noprefix true
    Test->>Repo: commit alpha.ts v2 (HEAD)
    Test->>Loader: loadFromRepo({ kind: "show" })
    Loader->>Loader: buildGitShowArgs() → withNormalizedDiffPrefixes()<br/>injects -c diff.srcPrefix=a/ -c diff.dstPrefix=b/
    Loader->>Git: git -c diff.srcPrefix=a/ -c diff.dstPrefix=b/ show HEAD
    Git-->>Loader: diff output (normalized prefixes)
    Loader-->>Test: bootstrap.changeset
    Test->>Test: assert files = ["alpha.ts"] ✓
Loading

Reviews (1): Last reviewed commit: "test: add missing noprefix test for hunk..." | Re-trigger Greptile

@benvinegar benvinegar merged commit af62ee4 into main Mar 24, 2026
3 checks passed
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.

1 participant