diff --git a/admin/sync/exceptions.go b/admin/sync/exceptions.go index 2ccc29dd..d5587aca 100644 --- a/admin/sync/exceptions.go +++ b/admin/sync/exceptions.go @@ -14,7 +14,7 @@ func (c *CheckExceptions) GetExerciceExceptions(e *fic.Exercice) *CheckException return c.GetFileExceptions(filepath.Base(e.Path)) } -func (c *CheckExceptions) GetFileExceptions(path string) *CheckExceptions { +func (c *CheckExceptions) GetFileExceptions(paths ...string) *CheckExceptions { if c == nil { return nil } @@ -22,14 +22,17 @@ func (c *CheckExceptions) GetFileExceptions(path string) *CheckExceptions { ret := CheckExceptions{} for k, v := range *c { - if strings.HasPrefix(k, "*:") || strings.HasPrefix(k, path) { - k = strings.TrimPrefix(k, path) + for _, path := range paths { + if strings.HasPrefix(k, "*:") || strings.HasPrefix(k, path) { + k = strings.TrimPrefix(k, path) - if strings.HasPrefix(k, "/") { - k = strings.TrimPrefix(k, "/") + if strings.HasPrefix(k, "/") { + k = strings.TrimPrefix(k, "/") + } + + ret[k] = v + break } - - ret[k] = v } } diff --git a/admin/sync/exercices.go b/admin/sync/exercices.go index 50c1ba7f..40c3d304 100644 --- a/admin/sync/exercices.go +++ b/admin/sync/exercices.go @@ -134,7 +134,7 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]* // Call checks hooks for _, h := range hooks.mdTextHooks { - for _, err := range h(e.Overview, exceptions.GetFileExceptions("overview.md")) { + for _, err := range h(e.Overview, exceptions.GetFileExceptions("overview.md", "overview.txt")) { errs = append(errs, NewExerciceError(e, fmt.Errorf("overview.md: %w", err))) } } @@ -164,7 +164,7 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]* } else { // Call checks hooks for _, h := range hooks.mdTextHooks { - for _, err := range h(e.Statement, exceptions.GetFileExceptions("statement.md")) { + for _, err := range h(e.Statement, exceptions.GetFileExceptions("statement.md", "statement.txt")) { errs = append(errs, NewExerciceError(e, fmt.Errorf("statement.md: %w", err))) } } @@ -181,7 +181,7 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]* } else { // Call checks hooks for _, h := range hooks.mdTextHooks { - for _, err := range h(e.Finished, exceptions.GetFileExceptions("finished.txt")) { + for _, err := range h(e.Finished, exceptions.GetFileExceptions("finished.md", "finished.txt")) { errs = append(errs, NewExerciceError(e, fmt.Errorf("finished.md: %w", err))) } } @@ -286,7 +286,7 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]* // Call checks hooks for _, h := range hooks.exerciceHooks { - for _, err := range h(e, exceptions.GetFileExceptions("challenge.txt")) { + for _, err := range h(e, exceptions) { errs = append(errs, NewExerciceError(e, err)) } } diff --git a/admin/sync/hooks.go b/admin/sync/hooks.go index b4509bce..8f31f0bb 100644 --- a/admin/sync/hooks.go +++ b/admin/sync/hooks.go @@ -7,7 +7,7 @@ import ( "srs.epita.fr/fic-server/libfic" ) -var hooks = &CheckHooks{} +var hooks = &CheckHooks{customHooks: map[string]CustomCheckHook{}} type CheckFlagChoiceHook func(*fic.FlagChoice, *CheckExceptions) []error type CheckFlagKeyHook func(*fic.FlagKey, string, *CheckExceptions) []error diff --git a/admin/sync/themes.go b/admin/sync/themes.go index 84c2c926..1e3796c8 100644 --- a/admin/sync/themes.go +++ b/admin/sync/themes.go @@ -144,7 +144,7 @@ func BuildTheme(i Importer, tdir string) (th *fic.Theme, exceptions *CheckExcept } else { // Call checks hooks for _, h := range hooks.mdTextHooks { - for _, err := range h(intro, exceptions.GetFileExceptions("overview.md")) { + for _, err := range h(intro, exceptions.GetFileExceptions("overview.md", "overview.txt")) { errs = append(errs, NewThemeError(th, fmt.Errorf("overview.md: %w", err))) } }