MCPcopy Create free account
hub / github.com/JordanCoin/codemap / FilterToChangedWithInfo

Function FilterToChangedWithInfo

scanner/git.go:125–144  ·  view source on GitHub ↗

FilterToChangedWithInfo filters and annotates files with diff info

(files []FileInfo, info *DiffInfo)

Source from the content-addressed store, hash-verified

123
124// FilterToChangedWithInfo filters and annotates files with diff info
125func FilterToChangedWithInfo(files []FileInfo, info *DiffInfo) []FileInfo {
126 var result []FileInfo
127 for _, f := range files {
128 path := f.Path
129 slashPath := filepath.ToSlash(f.Path)
130 if info.Changed[path] || info.Changed[slashPath] {
131 // Annotate with diff info
132 f.IsNew = info.Untracked[path] || info.Untracked[slashPath]
133 if stat, ok := info.Stats[path]; ok {
134 f.Added = stat.Added
135 f.Removed = stat.Removed
136 } else if stat, ok := info.Stats[slashPath]; ok {
137 f.Added = stat.Added
138 f.Removed = stat.Removed
139 }
140 result = append(result, f)
141 }
142 }
143 return result
144}
145
146// FilterAnalysisToChanged filters FileAnalysis slice to only changed files
147func FilterAnalysisToChanged(files []FileAnalysis, changed map[string]bool) []FileAnalysis {

Callers 4

buildBlastRadiusBundleFunction · 0.92
mainFunction · 0.92
handleGetDiffFunction · 0.92

Calls

no outgoing calls

Tested by 1