diff --git a/Gemfile b/Gemfile index ac74f27..f9a6c98 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Gemfile.lock b/Gemfile.lock index 5749a92..5be0148 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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! diff --git a/_posts/2023-04-15-give-credit-where-credit-s-due.md b/_posts/2023-04-15-give-credit-where-credit-s-due.md new file mode 100644 index 0000000..113a9ce --- /dev/null +++ b/_posts/2023-04-15-give-credit-where-credit-s-due.md @@ -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 "` + +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 \ + +[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 diff --git a/assets/gack-example.gif b/assets/gack-example.gif new file mode 100644 index 0000000..37b35f3 Binary files /dev/null and b/assets/gack-example.gif differ