Introducing Pair

by  • Sep 9, 2018

Published in Open-Source

You love attributing your pairs when committing code together? I certainly do. Yet after pairing for most of the past two years, I find myself once and again forgetting to do it and finding that writing my pairs’ names and email addresses is… repetitive.

Let me introduce pair, a tiny command-line tool that allows everyone to start their pairing sessions and switch pairs with a simple 🍐 command, while keeping control over what goes into their commit messages!

Where can I try it?

Releases

Binaries for official releases [1] may be downloaded from the releases page on GitHub. This is likely the quickest and easiest way to get started.

Source code

Pair is written in Go. Its source code is available on Github along with instructions to download it and install the command using Go’s tooling if that’s your thing.

Overview


$ pair with "Gonzalo <gonzalo.bulnes@redbubble.com>" # that's all!

# Wanna pair swap?
$ pair with "Alice <alice@example.com>"

# Never stop pairing!
# Well, if you do:
$ pair stop

Where does the idea come from?

Code written by a pair is often better (no matter what you understand by better) than code from a single author. Partly because of that (and partly because it’s fun!) people in my team started adding a note to mention who their pairs were in their commit messages.


Author: Alice <alice@example.com>
Date:   Mon Sep 10 15:02:32 2018 +1000

    Fix unicorns countdown in sky rocket

    The counter was being mistakenly reset as a side-effect
    of the re-fuelling. Removed unnecessary dependency between
    the two processes.

    Fixes #283

    🍐 Bob

Then, some time ago, Github introduced a convention for creating commits with multiple authors. The idea was extremely similar and our annotations could now be understood by Github!


Author: Bob <bob@example.com>
Date:   Tue Sep 11 14:01:44 2018 +1000

    Add rainbow slider to emergency kit

    Co-Authored-By: Alice <alice@exmple.com>

I like this feature: not only it allows Github to make visible when people are pairing together, but it also stays readable in a standard Git log.

We lost the emoji, which was a bit sad, but more annoyingly the annotation became a lot longer to type, and the email part made it error-prone. Mistakes made attribution sometimes frustrating and my eagerness for copy-pasting transformed my commit process into a somewhat complex endeavour.

How does Pair work?

Git has long supported commit templates, that is, files that hold the text that populates the text editor every time you git commit.

What if we could put the co-author declaration in there once and for all? Well… until we swap pairs? We can! Pair does exactly that.

There are subtleties, of course, like having a global template and different local ones in some repositories, but mostly, Pair handles that for you. It makes convenient to edit the template in use with a single command, so that you can focus on what you’re doing! 🍐

Contributing

At the time of writing, Pair’s pre-release (v1.0.0-alpha) is available. It is stable to use, and I expect mostly to catch cross-platform or usability issues. I am interested in your experience with it, as much as with errors that I may have missed.

If you download it and use it, and can feedback what you think and any bugs, inconsistencies that you experience, or indeed code smells that you find, I’ll be happy to pair together to fix them or move forward. : )

Conclusion

Go download it! (I’m kidding, no pressure.)

Pair could, I hope, make your pair programming sessions more enjoyable by removing one very little annoying moment from your practice. Hopefully, it can also make more visible the fact that collaboration is a two-way exchange, and everybody more keen on pairing together again!

  1. [1] I said everyone in the introduction: I would indeed appreciate input from people looking for using Pair on Windows. I have built Linux and OSX binaries so far, and would love to learn what's needed to support any other platform you care about.

Posted with tag: Open-Source