MCPcopy
hub / github.com/go-git/go-git / excludeIgnoredChanges

Method excludeIgnoredChanges

worktree_status.go:164–200  ·  view source on GitHub ↗
(changes merkletrie.Changes)

Source from the content-addressed store, hash-verified

162}
163
164func (w *Worktree) excludeIgnoredChanges(changes merkletrie.Changes) merkletrie.Changes {
165 patterns, err := gitignore.ReadPatterns(w.Filesystem, nil)
166 if err != nil {
167 return changes
168 }
169
170 patterns = append(patterns, w.Excludes...)
171
172 if len(patterns) == 0 {
173 return changes
174 }
175
176 m := gitignore.NewMatcher(patterns)
177
178 var res merkletrie.Changes
179 for _, ch := range changes {
180 var path []string
181 for _, n := range ch.To {
182 path = append(path, n.Name())
183 }
184 if len(path) == 0 {
185 for _, n := range ch.From {
186 path = append(path, n.Name())
187 }
188 }
189 if len(path) != 0 {
190 isDir := (len(ch.To) > 0 && ch.To.IsDir()) || (len(ch.From) > 0 && ch.From.IsDir())
191 if m.Match(path, isDir) {
192 if len(ch.From) == 0 {
193 continue
194 }
195 }
196 }
197 res = append(res, ch)
198 }
199 return res
200}
201
202func (w *Worktree) getSubmodulesStatus() (map[string]plumbing.Hash, error) {
203 o := map[string]plumbing.Hash{}

Callers 1

Calls 5

MatchMethod · 0.95
ReadPatternsFunction · 0.92
NewMatcherFunction · 0.92
NameMethod · 0.65
IsDirMethod · 0.65

Tested by

no test coverage detected