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

Function getCommitFiles

vcs/git/git_diff.go:269–288  ·  view source on GitHub ↗

getCommitFiles returns a list of all files changed in the specified commit (relative to repo root)

(repoPath, commitID string)

Source from the content-addressed store, hash-verified

267
268// getCommitFiles returns a list of all files changed in the specified commit (relative to repo root)
269func getCommitFiles(repoPath, commitID string) ([]string, error) {
270 // Use --root flag to handle root commits (first commit in repo)
271 // Use --diff-filter=d to exclude deleted files (only include added, modified, and renamed files)
272 stdout, stderr, err := runGitCommand(repoPath, "diff-tree", "--no-commit-id", "--name-only", "-r", "--root", "--diff-filter=d", commitID)
273 if err != nil {
274 return nil, gitCommandError(err, stderr)
275 }
276
277 // Parse the output - one file per line
278 var files []string
279 lines := strings.Split(string(stdout), "\n")
280 for _, line := range lines {
281 line = strings.TrimSpace(line)
282 if line != "" {
283 files = append(files, line)
284 }
285 }
286
287 return files, nil
288}
289
290// GetCommitDeletedFiles finds all files that were deleted by a specific commit.
291// Returns absolute paths. Their content no longer exists in the commit, so read

Callers 1

GetCommitDartFilesFunction · 0.85

Calls 2

runGitCommandFunction · 0.85
gitCommandErrorFunction · 0.85

Tested by

no test coverage detected