MCPcopy Create free account
hub / github.com/github/gh-aw / TrackModified

Method TrackModified

pkg/cli/file_tracker.go:63–80  ·  view source on GitHub ↗

TrackModified adds a file to the modified files list and stores its original content

(filePath string)

Source from the content-addressed store, hash-verified

61
62// TrackModified adds a file to the modified files list and stores its original content
63func (ft *FileTracker) TrackModified(filePath string) {
64 absPath, err := filepath.Abs(filePath)
65 if err != nil {
66 absPath = filePath
67 }
68
69 // Store original content if not already stored
70 if _, exists := ft.OriginalContent[absPath]; !exists {
71 if content, err := os.ReadFile(absPath); err == nil {
72 ft.OriginalContent[absPath] = content
73 fileTrackerLog.Printf("Tracking modified file: %s (stored %d bytes)", absPath, len(content))
74 } else {
75 fileTrackerLog.Printf("Tracking modified file: %s (failed to store original: %v)", absPath, err)
76 }
77 }
78
79 ft.ModifiedFiles = append(ft.ModifiedFiles, absPath)
80}
81
82// GetAllFiles returns all tracked files (created and modified)
83func (ft *FileTracker) GetAllFiles() []string {

Calls 1

PrintfMethod · 0.45

Tested by 2