GetCommitDartFiles finds all files that were changed in a specific commit. Returns absolute paths to all files added, modified, or renamed in the commit.
(repoPath, commitID string)
| 232 | // GetCommitDartFiles finds all files that were changed in a specific commit. |
| 233 | // Returns absolute paths to all files added, modified, or renamed in the commit. |
| 234 | func GetCommitDartFiles(repoPath, commitID string) ([]string, error) { |
| 235 | // Validate the repository path exists |
| 236 | if _, err := os.Stat(repoPath); os.IsNotExist(err) { |
| 237 | return nil, fmt.Errorf("repository path does not exist: %s", repoPath) |
| 238 | } |
| 239 | |
| 240 | // Verify it's a git repository |
| 241 | if !isGitRepository(repoPath) { |
| 242 | return nil, fmt.Errorf("%s is not a git repository (use 'git init' to initialize)", repoPath) |
| 243 | } |
| 244 | |
| 245 | // Validate the commit exists |
| 246 | if err := validateCommit(repoPath, commitID); err != nil { |
| 247 | return nil, err |
| 248 | } |
| 249 | |
| 250 | // Get the repository root |
| 251 | repoRoot, err := GetRepositoryRoot(repoPath) |
| 252 | if err != nil { |
| 253 | return nil, fmt.Errorf("failed to get repository root: %w", err) |
| 254 | } |
| 255 | |
| 256 | // Get files changed in the commit |
| 257 | commitFiles, err := getCommitFiles(repoPath, commitID) |
| 258 | if err != nil { |
| 259 | return nil, fmt.Errorf("failed to get files from commit: %w", err) |
| 260 | } |
| 261 | |
| 262 | // Convert to absolute paths (no filtering - include all files) |
| 263 | absolutePaths := toAbsolutePaths(repoRoot, commitFiles) |
| 264 | |
| 265 | return absolutePaths, nil |
| 266 | } |
| 267 | |
| 268 | // getCommitFiles returns a list of all files changed in the specified commit (relative to repo root) |
| 269 | func getCommitFiles(repoPath, commitID string) ([]string, error) { |