A Git Repository Manager — in Rust

Managing multiple repositories in a single place — with Rust

2021-12-04

I'm heavily using git both at work at for my personal projects. Over time, I ended up with a quite substantial amount of git repositories. For now, I've just been managing them manually. This worked well, but when setting up a new machine, I'd have to either restore a backup or do a lot of git clones manually.

I'm also a huge proponent of $whatever-as-code, especially Terraform. I like to just have a configuration plus a tool that takes that configuration to configure $whatever.

So, I decided to build a tool to do that: Have a config of my git repositories, and the tool makes sure that everything is cloned & configured correctly. And so, the git repository manager (GRM) was born.

I chose Rust for this project. I already used Rust for a few very small projects (<100 LOC), and for the backend of a package list application. I'm really fond of a lot of aspects (see [this blogpost about error handling]({{< relref "./2021-09-26-error-handling-rust-vs-go.md" >}}) for example).

To be honest, the project is 50% "scratching my own itch" and 50% "I want to learn Rust and need a project". I think it succeeded for both, as I'm dogfooding GRM right now, both at home and at work, and I'm also starting to get a good grasp of Rust.

In the meantime, GRM gained a few additional capabilities. For example, you can generate a configuration from an existing tree of git repositories (would be quite a hassle to do this manually). Also, I wrote some code to manage git worktrees, which makes it much easier to juggle multiple branches at the same time.

In the following, I'll list the resources I used while learning rust and writing GRM, and a few lessons about Rust in particular.

Resources I used

The rust book is absolutely awesome. It's like a tutorial through the rust language that will also act as a reference for later when you look up concepts. I read it once from start to finish in the beginning. Of course, I couldn't remember everything, but it was good to already have heard of some concepts when I encountered them later on.

I also cross-read the Rustomonicon, which aims to explain in detail how unsafe works in rust. I haven't used unsafe at all for GRM, but it was still valuable to know about the concepts. Additionally, the Rustomonicon is just an exciting read.

There is another book called "Learn Rust With Entirely Too Many Linked Lists". It hammers home some concepts like ownership, while giving a thorough introduction into Rust stdlib components like Iterators, Rc, and Arc.

Last but not least, I cannot stress how awesome the rust reference documentation is. When starting, you'll most likely work a lot with the Option and Result types. Now take a look at the documentation for Option: It's not just a list of available methods. No, it also gives an intro about use cases for Option and when you'll encounter it, how to use it with match, and groups the methods into different use cases and describes them

What I learned about Rust


That's it! In short, Rust is awesome. If you want, check out GRM (Link to the documentation).