b42-fosters / b42_piscine_helpers

1 stars 0 forks source link

Check that `ex??` folders are in order #7

Open fedordikarev opened 7 months ago

fedordikarev commented 7 months ago

For example, if you miss ex02 folder, all the rest will not give you a score. It's up to the user to decide what to submit, so I suggest that it should be "warning/informal", but for sure we should notify if there are ex01 and ex03 folders, but no ex02.

My guess, sort and awk should make it works.

cubernetes commented 7 months ago

What about this:

# Check for submission folder inconsistencies
last_folder_num="$(find -maxdepth 1 -type d -name 'ex[0-9][0-9]' -exec basename -- {} \; | sort -n | tail -1 | cut -c3-)"
folder_error=0
for expected_folder in $(seq -f 'ex%02g' $last_folder_num); do
    [ -d "$expected_folder" ] || { folder_error=1; break; }
done
echo "$folder_error"

Might not be BSD friendly, e.g. I'm not sure if the tail -1 syntax works or if you have to say tail -n1, or BSD seq has those flags

fedordikarev commented 7 months ago

looks good start! lets follow the next flow:

  1. please assign task to yourself, so others know you work on it and there will be no duplicate of efforts.
  2. as for code: my idea that it should be "warning". We don't have warnings yet in the mail logic: either OK or FAIL. So we need to think how to treat them.
  3. it will be good if we will print all the missing folder, not only first absent and exit.
  4. lets create a branch, move code there and lets follow up discussion in PR if needed.
  5. either use "create a branch" from here, or add a link for that issue into PR, so they will be "linked" and it will be easier to track. Screenshot 2024-03-22 at 16 50 01

@cubernetes

fedordikarev commented 7 months ago

and lets no bother much about BSD-ness of solution, lets take Ubuntu as our main target. MacOs and BSD users like me should care by themselves :) also curious if we can use comm for that...