BRIEFS logo BRIEFS

Automation with Cypress: Renaming GitHub Repo Default Branches

01/26/2021 , 2m, 41s

https://github.com/kentcdodds/rename-gh-to-main

Hello there friends. So today I'm going to talk about what I did yesterday and that is I spent just like an hour to renaming all of the default branches on my GitHub repos from Master to Maine. Now, I'm not going to really explain directly why I actually have a article that you can go read but Git and and GitHub are moving the default branch from master to main fork historical reasons and you know references to slavery and that sort of thing.

And so I decided I wanted to support that and I wanted to.Get everything consistent but I have over almost 300 repositories where it's the source repository not a fork I have. Yeah, just a lot of repositories. I didn't want to spend all the time. And as far as I know there's no GitHub API for for updating the default branch from Master to Maine.

And so I needed to use the UI. So what I did yesterday is I actually livestream this and you can go watch it, but I used Cyprus to automate navigating to every one of these repos. I wanted to and,Rename and we'd go to the slash branches URL for each one of the repos and select the the little edit button for the default branch and then enter main as the name and then you know rename the branch and click that button.

It was actually pretty straightforward. They're just a handful of lines of code and it's all open source you can go take a look at how it it's all set up but it was really cool to write this really quick. Cyprus quote-unquote test automation and and see it in the browser and what was cool is the way that I was able.

To develop it because Cypress actually pulls up a real browser and you can interact with that browsing you can type in and because I was live streaming I didn't want to actually have Cyprus enter in my username and password so I was able to have it pause the execution of the test so that I could take the browser off of the window and type in my username and password and then have a proceed and and go through everything.

So you should go take a look at that. It was like an hour and a half you could speed it up and just skip to the parts that are interesting. But yeah, it was pretty pretty cool and I I like using Cyprus for this sort of thing.If you were doing like legit long-term web scraping or something, maybe puppeteer would be a better fit but Cyprus makes manual processes like this like just so nice and easy.

So yeah give that a look. It's kind of interesting and I hope that you find it fascinating and fun and I hope you have a marvelous day. Bye.