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

Function getCommitFileStatuses

vcs/git/git_stats.go:330–369  ·  view source on GitHub ↗

getCommitFileStatuses returns a map of file paths to their status codes for a commit

(repoPath, commitID string)

Source from the content-addressed store, hash-verified

328
329// getCommitFileStatuses returns a map of file paths to their status codes for a commit
330func getCommitFileStatuses(repoPath, commitID string) (map[string]string, error) {
331 stdout, stderr, err := runGitCommand(repoPath, "show", "--name-status", "--format=", commitID)
332 if err != nil {
333 return nil, gitCommandError(err, stderr)
334 }
335
336 statuses := make(map[string]string)
337 lines := strings.Split(string(stdout), "\n")
338 for _, line := range lines {
339 line = strings.TrimSpace(line)
340 if line == "" {
341 continue
342 }
343
344 parts := strings.Split(line, "\t")
345 if len(parts) < 2 {
346 continue
347 }
348
349 status := parts[0]
350 var filePath string
351 if strings.HasPrefix(status, "R") || strings.HasPrefix(status, "C") {
352 if len(parts) < 3 {
353 continue
354 }
355 filePath = parts[2]
356 } else {
357 filePath = parts[1]
358 }
359
360 if filePath == "" {
361 continue
362 }
363
364 normalized := filepath.Clean(filePath)
365 statuses[normalized] = status
366 }
367
368 return statuses, nil
369}
370
371// getCommitRangeFileStatuses returns a map of file paths to their status codes for a commit range
372func getCommitRangeFileStatuses(repoPath, fromCommit, toCommit string) (map[string]string, error) {

Callers 1

GetCommitFileStatsFunction · 0.85

Calls 2

runGitCommandFunction · 0.85
gitCommandErrorFunction · 0.85

Tested by

no test coverage detected