getCommitFiles returns a list of all files changed in the specified commit (relative to repo root)
(repoPath, commitID string)
| 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) { |
| 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 |
no test coverage detected