There is a handful of Ruby gems that work with Git repositories. All of them have one thing in common: they focus on the repository. They provide a more or less sophisticated object–oriented interface to the repository, commits, refs, etc – either wrapping libgit2 (like Rugged), or building their own implementation (like a sadly incomplete object-oriented API of Grit). They all come short when I need to talk with the Git command line — which is a proper API on its own. Grit was a closest match with its Grit::Git class, but to use it effectively I needed to not use rest of the library (and thus adding dead weight to my scripts), and deal with the fact that it always captures command’s output — there was no way to just call git diff, and have end user see the output in colors they defined and with pager they configured. To add insult to injury, when the Git command returns an error, Grit silently ignores it.
What I needed was essentially
system('git', …) or
`git …`, possibly tied to a specific repository, with a tiny bit of syntactic sugar on top. Using Grit just to throw away 90% of the code, and then add some to deal with the remaining rough edges (or deal with the always–capturing interface), seemed like pushing a square peg into the round hole. Thus, MiniGit was born. 135 lines of code, no dependencies outside of stdlib, tested with MRI 1.8.7 to 2.0.0, REE, JRuby and Rubinius, and providing just the simple layer to comfortably talk with the Git command line. Just what I needed for Vendorificator and a bunch of glue scripts in various places.