github / gh-classroom

GitHub Classroom CLI Extension is a powerful and easy-to-use command line tool that enhances the functionality of the GitHub CLI, specifically tailored for educators using GitHub Classroom.
MIT License
82 stars 14 forks source link

The new `gh classroom pull` command fails if any other files are in target directory #58

Closed physcrowley closed 10 months ago

physcrowley commented 11 months ago

This may be similar to issue #14 but I have put test files that I use to test student submissions locally in the "submissions-x" folder, and just noticed that the pull command fails at this point (I have aliased the full gh classroom pull student-repos with my own pull script):

PS C:\Users\physcrowley\Documents\ics4u\23-01> pull
? Select a classroom: ICS4U-Crowley-2023-24
? Select an assignment: encapsulated
Pulling repo: C:\Users\physcrowley\Documents\ics4u\23-01\encapsulated-submissions\TeacherTest.java
2023/11/05 15:18:49 chdir C:\Users\physcrowley\Documents\ics4u\23-01\encapsulated-submissions\TeacherTest.java: The directory name is invalid.
PS C:\Users\physcrowley\Documents\ics4u\23-01\encapsulated-submissions> ls

    Directory: C:\Users\physcrowley\Documents\ics4u\23-01\encapsulated-submissions

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        2023-11-02   1:20 PM                encapsulated-redacted
d-----        2023-11-02   1:21 PM                encapsulated-redacted
d-----        2023-11-02   1:21 PM                encapsulated-redacted
d-----        2023-11-02   1:21 PM                encapsulated-redacted
d-----        2023-11-02   1:22 PM                encapsulated-redacted
d-----        2023-11-02   1:22 PM                encapsulated-redacted
d-----        2023-11-02   1:22 PM                encapsulated-redacted
d-----        2023-11-02   1:22 PM                encapsulated-redacted
-a----        2023-11-02  11:17 AM            361 build.xml
-a----        2023-11-02   1:25 PM            442 runAllTests.ps1
-a----        2023-11-02   1:16 PM            110 TeacherTest.java

@shanep - love the new pull feature, btw, and have stopped maintenance on my own set of tools in favor of this one.

shanep commented 11 months ago

Hi @physcrowley,

If you have uncommitted changed in the repo a pull should fail as this is how git is designed. If you want to put files in their repos to support grading then the best approach is to add those files to a .gitignore in your starter code repo. Then everything should work as advertised.

Hopefully this helps out :)

-Shane

physcrowley commented 11 months ago

I run git clean -f -d as part of the post-test cleanup on the student repos and don't otherwise touch their files, so my local repos are clean.

The pull is failing because the script thinks a file in the root folder, TeacherTest.java, is a student repo. I'm not familiar with the language used to make the gh script, but I could attempt to add an appropriate guard clause and submit a pull request.

physcrowley commented 11 months ago

it looks like I would need to filter entries at this line before heading into the for loop: https://github.com/github/gh-classroom/blob/aff764e5a50780e0fbcf731a5baaef1bb62b5b20/cmd/gh-classroom/pull/student-repos/student-repos.go#L78

shanep commented 11 months ago

@physcrowley I was just going to implement this fix and saw you already had :) Nice work!

physcrowley commented 11 months ago

I will look into the starter code option too, but many of my current projects are based on the same blank starter code even though the tests will be different. That's a mod for the next set of starter templates.