MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / TestGetCommitFileDiffs

Function TestGetCommitFileDiffs

vcs/git/git_diff_lines_test.go:97–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestGetCommitFileDiffs(t *testing.T) {
98 tmpDir := t.TempDir()
99 setupGitRepo(t, tmpDir)
100
101 createFile(t, tmpDir, "lib.rs", "line a\nline b\nline c\n")
102 gitAdd(t, tmpDir, "lib.rs")
103 gitCommit(t, tmpDir, "initial")
104
105 createFile(t, tmpDir, "lib.rs", "line a\nline b2\nline c\nline d\n")
106 gitAdd(t, tmpDir, "lib.rs")
107 sha := gitCommitAndGetSHA(t, tmpDir, "second")
108
109 diffs, err := GetCommitFileDiffs(tmpDir, sha)
110 require.NoError(t, err)
111
112 resolvedDir, err := filepath.EvalSymlinks(tmpDir)
113 require.NoError(t, err)
114 fd, ok := diffs[filepath.Join(resolvedDir, "lib.rs")]
115 require.True(t, ok)
116 assert.Equal(t, []int{2}, fd.Deletions, "original line 2 (line b) removed")
117 assert.Equal(t, []int{2, 4}, fd.Additions, "new line 2 (line b2) and new line 4 (line d)")
118}
119
120func TestGetCommitFileDiffs_RootCommit(t *testing.T) {
121 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 6

setupGitRepoFunction · 0.85
createFileFunction · 0.85
gitAddFunction · 0.85
gitCommitFunction · 0.85
gitCommitAndGetSHAFunction · 0.85
GetCommitFileDiffsFunction · 0.85

Tested by

no test coverage detected