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

Function getUncommittedFileStatuses

vcs/git/git_stats.go:296–327  ·  view source on GitHub ↗

getUncommittedFileStatuses returns a map of relative file paths to their git status codes

(repoPath string)

Source from the content-addressed store, hash-verified

294
295// getUncommittedFileStatuses returns a map of relative file paths to their git status codes
296func getUncommittedFileStatuses(repoPath string) (map[string]string, error) {
297 stdout, stderr, err := runGitCommand(repoPath, "status", "--porcelain", "--untracked-files=all")
298 if err != nil {
299 return nil, gitCommandError(err, stderr)
300 }
301
302 statuses := make(map[string]string)
303 lines := strings.Split(string(stdout), "\n")
304 for _, line := range lines {
305 if len(line) < 4 {
306 continue
307 }
308
309 status := line[:2]
310 filePath := strings.TrimSpace(line[3:])
311
312 // Handle renamed files (format: "old -> new")
313 if strings.Contains(filePath, " -> ") {
314 parts := strings.Split(filePath, " -> ")
315 filePath = parts[1]
316 }
317
318 if filePath == "" {
319 continue
320 }
321
322 normalized := filepath.Clean(filePath)
323 statuses[normalized] = status
324 }
325
326 return statuses, nil
327}
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) {

Callers 3

GetUncommittedFileStatsFunction · 0.85
GetUncommittedFileDiffsFunction · 0.85

Calls 2

runGitCommandFunction · 0.85
gitCommandErrorFunction · 0.85

Tested by

no test coverage detected