MCPcopy Create free account
hub / github.com/go-git/go-git / excludeIgnoredChanges

Method excludeIgnoredChanges

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

Source from the content-addressed store, hash-verified

145}
146
147func (w *Worktree) excludeIgnoredChanges(changes merkletrie.Changes) merkletrie.Changes {
148 patterns, err := gitignore.ReadPatterns(w.Filesystem, nil)
149 if err != nil {
150 return changes
151 }
152
153 patterns = append(patterns, w.Excludes...)
154
155 if len(patterns) == 0 {
156 return changes
157 }
158
159 m := gitignore.NewMatcher(patterns)
160
161 var res merkletrie.Changes
162 for _, ch := range changes {
163 var path []string
164 for _, n := range ch.To {
165 path = append(path, n.Name())
166 }
167 if len(path) == 0 {
168 for _, n := range ch.From {
169 path = append(path, n.Name())
170 }
171 }
172 if len(path) != 0 {
173 isDir := (len(ch.To) > 0 && ch.To.IsDir()) || (len(ch.From) > 0 && ch.From.IsDir())
174 if m.Match(path, isDir) {
175 if len(ch.From) == 0 {
176 continue
177 }
178 }
179 }
180 res = append(res, ch)
181 }
182 return res
183}
184
185func (w *Worktree) getSubmodulesStatus() (map[string]plumbing.Hash, error) {
186 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