admin/sync: Able to filter on the second column

This commit is contained in:
nemunaire 2022-11-02 17:42:08 +01:00
parent 3d35cee67d
commit 7b2603afb0
2 changed files with 23 additions and 1 deletions

View File

@ -47,6 +47,28 @@ func (c *CheckExceptions) GetFileExceptions(paths ...string) *CheckExceptions {
return &ret return &ret
} }
func (c *CheckExceptions) Filter2ndCol(str string) *CheckExceptions {
if c == nil {
return nil
}
ret := CheckExceptions{}
for k, v := range *c {
cols := strings.SplitN(k, ":", 3)
if len(cols) < 2 {
continue
}
if eval, err := filepath.Match(cols[1], str); err == nil && eval {
ret[k] = v
break
}
}
return &ret
}
func (c *CheckExceptions) HasException(ref string) bool { func (c *CheckExceptions) HasException(ref string) bool {
if c == nil { if c == nil {
return false return false

View File

@ -118,7 +118,7 @@ func buildLabelFlag(exercice *fic.Exercice, flag ExerciceFlag, flagline int, exc
// Call checks hooks // Call checks hooks
for _, h := range hooks.flagLabelHooks { for _, h := range hooks.flagLabelHooks {
for _, e := range h(f, exceptions) { for _, e := range h(f, exceptions.Filter2ndCol(strconv.Itoa(flagline))) {
errs = append(errs, NewFlagError(exercice, &flag, flagline, e)) errs = append(errs, NewFlagError(exercice, &flag, flagline, e))
} }
} }