pair, a git author tool

Simplifying authorship in pair programming.

Written by Brian Donovan.

Software engineers at Square sometimes write code by themselves, and sometimes with others. When we write code with others at the same computer we call that “pair programming” or “pairing”. We use this technique in our interviews, and in our work when appropriate. When we’re ready to commit our work in our version control system, git, we want to ensure that all the authors are listed for posterity.

When I started we had a few different ways of solving this problem. Some people used a ruby gem, some had written their own tool for the job, and some simply edited their git author configuration by hand every time. I wanted a way to quickly expand names and create a joint email alias for all the authors of a commit, and I didn’t want it to work only at the whim of my current ruby and rvm configuration.

I decided to write pair in Go as a way to teach myself a little bit of the language and to make sure it was fast and reliable. It’s installed by default on all the machines at Square, including our interview machines. It’s great for any group that has a reasonably stable list of people, like the engineering group in a company or open source projects that do pair programming. Here’s how you use it:

$ pair mb lb
Lindsay Bluth and Michael Bluth <[email protected]>

Use it with an arbitrary number of authors:

$ pair l c m
Curly and Larry and Moe <[email protected]>

And you can use it to restore your git author configuration to normal:

$ pair lb
Lindsay Bluth <[email protected]>

A YAML file at ~/.pairs maps usernames to full names:

c: Curly
l: Larry
lb: Lindsay Bluth
m: Moe
mb: Michael Bluth

This simple tool is used frequently at Square, and I hope it’s useful for you too. For more information or to install it on your machine, check it out on GitHub. Brian Donovan - Profile *I build digital things for @Square, mostly web sites.*medium.com