I use GitHub for almost all of my classes, and each class has its own named organization. Students and teams submit work through GitHub, which means that there are a lot of repositories built up in the organization by the end of the semester. I always tell my students to make their own copies or forks and then to clean their work out of the GitHub organization, but very few actually do this. Because I reuse the organizations, this leaves it up to me to clean out the repositories between semesters.
Deleting repositories by hand is tedious. For reasons I cannot explain, Repo Remover only shows a small subset of the repositories in the organization, and Repo Sweeper shows none. This morning, after taking out a few with Repo Remover, I started the process of removing repositories one at a time. Two thoughts crossed my mind: "Automate tedious manual work" and "Don't spend more time writing a program than you will save doing it by hand." Well, since I have to do this between every semester, I decided I had had enough tedium.
I've been quietly working on a Summer project using Flutter, and so after confirming that there's a nice library to wrap GitHub's API, I decided to see if I could whip something up in Dart. My major stumbling block was not realizing that a variable exported within Android Studio's terminal would not be available in the execution environment of the IDE. Once I specified my personal access token in the run configuration instead, everything worked like a charm. There's really hardly any code to it, and I've released it under GPL on GitHub at https://github.com/doctor-g/repo_deleter.
The code obviously would need to be modified for others' purposes. Right now, the "bsu-cs315" organization is hard-coded, and there's no UX to speak of. It just deletes all the repositories that start with the letter "P". Of course, I didn't start with that code. I started by having it print all the organization repositories, then I filtered out those I didn't want, and then I changed my print statement to a deletion.
Hopefully this will save me headaches next time I need to clean out an organization. Also, hopefully by writing this blog post, I will remember that I wrote a tool to make my life a little easier.
No comments:
Post a Comment