MCPcopy Create free account
hub / github.com/exercism/cli / filesBelongToSameExercise

Method filesBelongToSameExercise

cmd/submit.go:368–395  ·  view source on GitHub ↗

filesBelongToSameExercise checks that each file belongs to the same exercise.

(submitPaths []string)

Source from the content-addressed store, hash-verified

366
367// filesBelongToSameExercise checks that each file belongs to the same exercise.
368func (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.
398func (s submitValidator) fileSizesWithinMax(submitPaths []string) error {

Callers 1

runSubmitFunction · 0.80

Calls 3

NewFunction · 0.92
IsMissingMetadataFunction · 0.92
ExerciseDirMethod · 0.80

Tested by

no test coverage detected