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

Function GetCommitRangeFileDiffs

vcs/git/git_diff_lines.go:99–113  ·  view source on GitHub ↗

GetCommitRangeFileDiffs returns per-line additions and deletions for files changed between two commits. Inputs are the same as `git diff from..to`.

(repoPath, fromCommit, toCommit string)

Source from the content-addressed store, hash-verified

97// GetCommitRangeFileDiffs returns per-line additions and deletions for files
98// changed between two commits. Inputs are the same as `git diff from..to`.
99func GetCommitRangeFileDiffs(repoPath, fromCommit, toCommit string) (map[string]vcs.FileDiff, error) {
100 if !isGitRepository(repoPath) {
101 return nil, fmt.Errorf("%s is not a git repository", repoPath)
102 }
103 repoRoot, err := GetRepositoryRoot(repoPath)
104 if err != nil {
105 return nil, fmt.Errorf("failed to get repository root: %w", err)
106 }
107
108 stdout, stderr, err := runGitCommand(repoPath, "diff", "--unified=0", "--no-color", fromCommit, toCommit)
109 if err != nil {
110 return nil, gitCommandError(err, stderr)
111 }
112 return absolutize(repoRoot, parseUnifiedDiff(string(stdout))), nil
113}
114
115func absolutize(repoRoot string, diffs map[string]vcs.FileDiff) map[string]vcs.FileDiff {
116 out := make(map[string]vcs.FileDiff, len(diffs))

Callers 1

annotateRustPhantomsFunction · 0.92

Calls 6

isGitRepositoryFunction · 0.85
GetRepositoryRootFunction · 0.85
runGitCommandFunction · 0.85
gitCommandErrorFunction · 0.85
absolutizeFunction · 0.85
parseUnifiedDiffFunction · 0.85

Tested by

no test coverage detected