FilterToChangedWithInfo filters and annotates files with diff info
(files []FileInfo, info *DiffInfo)
| 123 | |
| 124 | // FilterToChangedWithInfo filters and annotates files with diff info |
| 125 | func 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 |
| 147 | func FilterAnalysisToChanged(files []FileAnalysis, changed map[string]bool) []FileAnalysis { |
no outgoing calls