MCPcopy
hub / github.com/git-lfs/git-lfs / listPatterns

Function listPatterns

commands/command_track.go:259–309  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

257}
258
259func listPatterns() {
260 knownPatterns, err := getAllKnownPatterns()
261 if err != nil {
262 Exit("unable to list patterns: %s", err)
263 }
264 if trackJSONFlag {
265 patterns := struct {
266 Patterns []PatternData `json:"patterns"`
267 }{Patterns: make([]PatternData, 0, len(knownPatterns))}
268 for _, p := range knownPatterns {
269 patterns.Patterns = append(patterns.Patterns, PatternData{
270 Pattern: p.Path,
271 Source: p.Source.String(),
272 Tracked: p.Tracked,
273 Lockable: p.Lockable,
274 })
275 }
276 encoder := json.NewEncoder(os.Stdout)
277 encoder.SetIndent("", " ")
278 err := encoder.Encode(patterns)
279 if err != nil {
280 ExitWithError(err)
281 }
282 return
283 }
284
285 if len(knownPatterns) < 1 {
286 return
287 }
288
289 Print(tr.Tr.Get("Listing tracked patterns"))
290 for _, t := range knownPatterns {
291 if t.Lockable {
292 // TRANSLATORS: Leading spaces here should be preserved.
293 Print(tr.Tr.Get(" %s [lockable] (%s)", t.Path, t.Source))
294 } else if t.Tracked {
295 Print(" %s (%s)", t.Path, t.Source)
296 }
297 }
298
299 if trackNoExcludedFlag {
300 return
301 }
302
303 Print(tr.Tr.Get("Listing excluded patterns"))
304 for _, t := range knownPatterns {
305 if !t.Tracked && !t.Lockable {
306 Print(" %s (%s)", t.Path, t.Source)
307 }
308 }
309}
310
311func getAllKnownPatterns() ([]git.AttributePath, error) {
312 mp := gitattr.NewMacroProcessor()

Callers 1

trackCommandFunction · 0.85

Calls 7

getAllKnownPatternsFunction · 0.85
ExitFunction · 0.85
ExitWithErrorFunction · 0.85
PrintFunction · 0.85
EncodeMethod · 0.80
StringMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected