Migrating issues from GitHub to Codeberg
In the course of porting a project from (several) GitHub repositories to a (single) Codeberg repository, I found that I wanted to be able to migrate the issues. So I wrote a script to do that.
A note up front, if you let the Codeberg site do the migration for you, for a 1:1 copy off of GitHub onto Codeberg, that migration does a (lot) better job migrating issues than this script. If that’s what you need, you don’t need this.
I was facing a couple of challenges. First, I’ve moved some repositories “by hand” so I don’t have the nicely migrated issues. This will help me fix that.
But second, I also want to merge several GitHub repositories into a single CodebergPast me structured a complicated project as three separate repositories instead of several subprojects in a single repository. In retrospect, past me got that very, very wrong. (Past me knew less about Gradle at the time and didn’t really forsee some of the challenges associated with having related builds in separate repositories.) repository. I could probably do that on the GitHub side and then migrate the result, but that feels like it could really muddy the waters. I don’t plan to push any of the build system updates that allow the new, combined repository to build the project to GitHub or test them there. So the GitHub merged repository would be in a very disorganized state.
In principle, I could have just done this by hand, but that would have been a lot of fiddly work and I wouldn’t have enjoyed it. (This side quest was also a lot of fiddly work, and I wouldn’t say that I exactly enjoyed it, but at least it’s reusable.)
What it does is use the respective APIs to read the issues from GitHub and write them to Codeberg. In principle, it could go the other way too. And in principle, it could be made to work with any other forge that provides a sufficient API. But I didn’t write any of those parts because I don’t need them.
Shout out to Achim Berndzen for encouraging me to make the provenance for issues and comments clearer. It’s not pretty, because all of the issues and comments created by the script are owned by the user associated with the Codeberg API token. As it has to be. But it’s better than what I had in earlier versions.
The script is on Codeberg. If you want to try it out, I strongly encourage you to make a test respository and migrate some issues to it. Make sure you like the results before you mess up some “real” repository.
Share and enjoy.