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

Function GetCommitRenames

vcs/git/git_diff.go:124–141  ·  view source on GitHub ↗

GetCommitRenames returns git's own rename detection for a single commit (old path -> new path, absolute), mirroring `git diff -M`. Old content lives in the commit's first parent.

(repoPath, commitID string)

Source from the content-addressed store, hash-verified

122// path -> new path, absolute), mirroring `git diff -M`. Old content lives in the
123// commit's first parent.
124func GetCommitRenames(repoPath, commitID string) (map[string]string, error) {
125 if !isGitRepository(repoPath) {
126 return nil, fmt.Errorf("%s is not a git repository (use 'git init' to initialize)", repoPath)
127 }
128 if err := validateCommit(repoPath, commitID); err != nil {
129 return nil, err
130 }
131 repoRoot, err := GetRepositoryRoot(repoPath)
132 if err != nil {
133 return nil, fmt.Errorf("failed to get repository root: %w", err)
134 }
135
136 stdout, stderr, err := runGitCommand(repoPath, "diff-tree", "-M", "--no-commit-id", "-r", "--root", "--diff-filter=R", "--name-status", commitID)
137 if err != nil {
138 return nil, gitCommandError(err, stderr)
139 }
140 return parseRenameNameStatus(stdout, repoRoot), nil
141}
142
143// GetCommitRangeRenames returns git's rename detection between two commits.
144func GetCommitRangeRenames(repoPath, fromCommit, toCommit string) (map[string]string, error) {

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