diff --git a/admin/sync/exceptions.go b/admin/sync/exceptions.go index 32d17186..ca736a55 100644 --- a/admin/sync/exceptions.go +++ b/admin/sync/exceptions.go @@ -47,6 +47,28 @@ func (c *CheckExceptions) GetFileExceptions(paths ...string) *CheckExceptions { 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 { if c == nil { return false diff --git a/admin/sync/exercice_keys.go b/admin/sync/exercice_keys.go index ee6071e5..b8cd63dc 100644 --- a/admin/sync/exercice_keys.go +++ b/admin/sync/exercice_keys.go @@ -118,7 +118,7 @@ func buildLabelFlag(exercice *fic.Exercice, flag ExerciceFlag, flagline int, exc // Call checks hooks 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)) } }