admin/sync: Keep Exceptions from multiple files
This commit is contained in:
parent
ac25202024
commit
23ac512ce6
4 changed files with 16 additions and 13 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue