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

Function GetUncommittedFiles

vcs/git/git_diff.go:13–40  ·  view source on GitHub ↗

GetUncommittedFiles finds all uncommitted files in a git repository. Returns absolute paths to all uncommitted files (staged, unstaged, and untracked).

(repoPath string)

Source from the content-addressed store, hash-verified

11// GetUncommittedFiles finds all uncommitted files in a git repository.
12// Returns absolute paths to all uncommitted files (staged, unstaged, and untracked).
13func GetUncommittedFiles(repoPath string) ([]string, error) {
14 // Validate the repository path exists
15 if _, err := os.Stat(repoPath); os.IsNotExist(err) {
16 return nil, fmt.Errorf("repository path does not exist: %s", repoPath)
17 }
18
19 // Verify it's a git repository
20 if !isGitRepository(repoPath) {
21 return nil, fmt.Errorf("%s is not a git repository (use 'git init' to initialize)", repoPath)
22 }
23
24 // Get the repository root
25 repoRoot, err := GetRepositoryRoot(repoPath)
26 if err != nil {
27 return nil, fmt.Errorf("failed to get repository root: %w", err)
28 }
29
30 // Get all uncommitted files
31 uncommittedFiles, err := getUncommittedFiles(repoPath)
32 if err != nil {
33 return nil, fmt.Errorf("failed to get uncommitted files: %w", err)
34 }
35
36 // Convert to absolute paths (no filtering - include all files)
37 absolutePaths := toAbsolutePaths(repoRoot, uncommittedFiles)
38
39 return absolutePaths, nil
40}
41
42// GetUncommittedDeletedFiles returns absolute paths for tracked files deleted
43// from the current working tree or index.

Calls 4

isGitRepositoryFunction · 0.85
GetRepositoryRootFunction · 0.85
getUncommittedFilesFunction · 0.85
toAbsolutePathsFunction · 0.85