And new post: git attribution (#4)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

Reviewed-on: #4
This commit is contained in:
Andrew Tomaka 2023-04-16 12:27:16 -04:00
parent 017279d727
commit d1d470fe0c
4 changed files with 79 additions and 0 deletions

View file

@ -16,6 +16,7 @@ gem "no-style-please", git: "https://github.com/atomaka/no-style-please", branch
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-compose"
gem "jekyll-feed", "~> 0.12"
gem "jekyll-gist"
gem "jekyll-tidy"

View file

@ -58,6 +58,8 @@ GEM
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
jekyll-compose (0.12.0)
jekyll (>= 3.7, < 5.0)
jekyll-feed (0.17.0)
jekyll (>= 3.7, < 5.0)
jekyll-gist (1.5.0)
@ -135,6 +137,7 @@ PLATFORMS
DEPENDENCIES
http_parser.rb (~> 0.6.0)
jekyll (~> 4.3.2)
jekyll-compose
jekyll-feed (~> 0.12)
jekyll-gist
jekyll-import!

View file

@ -0,0 +1,75 @@
---
layout: post
title: Give credit where credit's due
date: 2023-04-15 09:17 -0400
---
I love pair programming. It is a great way to improve solutions, share context,
and continuously review code. But the passenger in a pairing session often ends
up being the unsung hero, not showing up in the commit history for their
invaluable contributions because they were not typing on the keyboard.
Commit logs are obviously not the authority on an individual's contributions to
a codebase, but I still like to give credit where credit is due. Fortunately,
using git's [trailers][1], Github allows you to [commit together][2]. Including
a `Co-authored-by:` citation with your pairing partner's name and email will
properly attribute them in Github's commit log.
I have used this to share credit for several years, but it is a bit painful.
Making sure to type your partner's name and email is a hassle. Any typo will
not credit appropriately and become permanantly engraved in the history of your
repository when you merge it to master!
So avoid the typos!
First, I created a simple git alias that will allow me to easily modify a commit
to add a trailer. In your global `.gitconfig` file, add
```
[alias]
add-trailer = commit --no-edit --amend --trailer
```
This can be used as part of a two step process:
1. Make your commit as you normally would
1. Use the alias to add a trailer
- `git add-trailer "Co-authored-by: Partner <a@example.com>"`
We can still have typos though. But if our pairing partner has worked on this
repository in the past, we can find their information in the git log. This is
still painful to do manually. [Fzf][3] can help us here though. We can pass our
log information into fzf and then pass our selection on to our newly created git
alias:
```
git log --pretty="%an <%ae>" \
| sort -u \
| fzf \
| xargs -I "{}" git add-trailer "Co-authored-by: {}"
```
Breaking this down:
- `git log --pretty="%an <%ae>"`
- List the author of every commit in our repositry and format it appropriately
for attribution
- `sort -u`
- Make the list sorted and unique
- `fzf`
- Prompt us to make a selection from the list
- `xargs -I "{}" git add-trailer "Co-authored-by: {}"`
- Take the result from our prompt and pass it into our new git alias
And when everything is in place, attribution is a breeze!
![Example git acknowledge](/assets/gack-example.gif)
And in the spirit of attribution, thanks to last week's pairing partner:
Encouraged-by: nichol alexander \<nichol.alexander@gmail.com>
[1]: https://git-scm.com/docs/git-interpret-trailers
[2]: https://github.blog/2018-01-29-commit-together-with-co-authors/
[3]: https://github.com/junegunn/fzf

BIN
assets/gack-example.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB