filesBelongToSameExercise checks that each file belongs to the same exercise.
(submitPaths []string)
| 366 | |
| 367 | // filesBelongToSameExercise checks that each file belongs to the same exercise. |
| 368 | func (s submitValidator) filesBelongToSameExercise(submitPaths []string) error { |
| 369 | ws, err := workspace.New(s.usrCfg.GetString("workspace")) |
| 370 | if err != nil { |
| 371 | return err |
| 372 | } |
| 373 | |
| 374 | var exerciseDir string |
| 375 | for _, f := range submitPaths { |
| 376 | dir, err := ws.ExerciseDir(f) |
| 377 | if err != nil { |
| 378 | if workspace.IsMissingMetadata(err) { |
| 379 | return errors.New(msgMissingMetadata) |
| 380 | } |
| 381 | return err |
| 382 | } |
| 383 | if exerciseDir != "" && dir != exerciseDir { |
| 384 | msg := ` |
| 385 | |
| 386 | You are submitting files belonging to different solutions. |
| 387 | Please submit the files for one solution at a time. |
| 388 | |
| 389 | ` |
| 390 | return errors.New(msg) |
| 391 | } |
| 392 | exerciseDir = dir |
| 393 | } |
| 394 | return nil |
| 395 | } |
| 396 | |
| 397 | // fileSizesWithinMax checks that each file does not exceed the max allowed size. |
| 398 | func (s submitValidator) fileSizesWithinMax(submitPaths []string) error { |
no test coverage detected