(paths []string)
| 31 | } |
| 32 | |
| 33 | func Load(paths []string) (*Ruleset, error) { |
| 34 | var ( |
| 35 | allOwners codeowners.Ruleset |
| 36 | err error |
| 37 | ) |
| 38 | |
| 39 | if len(paths) == 0 { |
| 40 | allOwners, err = codeowners.LoadFileFromStandardLocation() |
| 41 | if err != nil { |
| 42 | return nil, fmt.Errorf("while loading: %w", err) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | for _, f := range paths { |
| 47 | coFile, err := os.Open(f) |
| 48 | if err != nil { |
| 49 | return nil, fmt.Errorf("while opening %s: %w", f, err) |
| 50 | } |
| 51 | defer coFile.Close() |
| 52 | |
| 53 | owners, err := codeowners.ParseFile(coFile) |
| 54 | if err != nil { |
| 55 | return nil, fmt.Errorf("while parsing %s: %w", f, err) |
| 56 | } |
| 57 | |
| 58 | allOwners = append(allOwners, owners...) |
| 59 | } |
| 60 | |
| 61 | return &Ruleset{ |
| 62 | Ruleset: allOwners, |
| 63 | }, nil |
| 64 | } |
| 65 | |
| 66 | func (r *Ruleset) WithExcludedOwners(excludedOwners []string) *Ruleset { |
| 67 | excluded := make(map[string]struct{}) |
no test coverage detected
searching dependent graphs…