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

Function GetCommitRangeRenames

vcs/git/git_diff.go:144–164  ·  view source on GitHub ↗

GetCommitRangeRenames returns git's rename detection between two commits.

(repoPath, fromCommit, toCommit string)

Source from the content-addressed store, hash-verified

142
143// GetCommitRangeRenames returns git's rename detection between two commits.
144func GetCommitRangeRenames(repoPath, fromCommit, toCommit string) (map[string]string, error) {
145 if !isGitRepository(repoPath) {
146 return nil, fmt.Errorf("%s is not a git repository (use 'git init' to initialize)", repoPath)
147 }
148 if err := validateCommit(repoPath, fromCommit); err != nil {
149 return nil, err
150 }
151 if err := validateCommit(repoPath, toCommit); err != nil {
152 return nil, err
153 }
154 repoRoot, err := GetRepositoryRoot(repoPath)
155 if err != nil {
156 return nil, fmt.Errorf("failed to get repository root: %w", err)
157 }
158
159 stdout, stderr, err := runGitCommand(repoPath, "diff", "-M", "--diff-filter=R", "--name-status", fromCommit, toCommit)
160 if err != nil {
161 return nil, gitCommandError(err, stderr)
162 }
163 return parseRenameNameStatus(stdout, repoRoot), nil
164}
165
166// parseRenameNameStatus parses `--name-status` rename rows ("R<score>\told\tnew")
167// into an absolute old->new map, or nil when there are none.

Callers 1

collectCommitRenamesFunction · 0.92

Calls 6

isGitRepositoryFunction · 0.85
validateCommitFunction · 0.85
GetRepositoryRootFunction · 0.85
runGitCommandFunction · 0.85
gitCommandErrorFunction · 0.85
parseRenameNameStatusFunction · 0.85

Tested by

no test coverage detected