No changelog, no problem

2019-05-20

"Happy Monday!" Your buddy over in Business Intelligence has a question. Some time on November 23rd, a specific tracked event dropped in frequency by half. Fortunately this isn't a mission-critical metric or you would have heard about it awhile ago. Still, what happened on November 23rd?

If you keep an official changelog, maybe your BI buddy can answer this on their own. Otherwise you're going to have to dig into your ol' reliable git log for help.

I've done this spelunking enough times now to write up a little script named what-shipped-on. Since we use feature-branches and merge into a release branch on deploy, we can run the script from the deployed branch to see what commits were merged on a date.

Example:

$ what-shipped-on 2019-05-20
commit 41abc0bd3960b47daadaf7fa1a8ee5bf68d38609
Author: Jeffrey Chupp <jeff@semanticart.com>
Date:   Mon May 20 11:44:06 2019 -0400

    Unify css files

commit c061f869e7ad1d6362d4a8d3836e513ca2a72e59
Author: Jeffrey Chupp <jeff@semanticart.com>
Date:   Mon May 20 11:07:12 2019 -0400

    WebP for images

Here's the script:

#!/usr/bin/env bash

if [[ $# -eq 0 ]] ; then
    echo 'Please provide a date in YYYY-MM-DD format.'
    exit 1
fi

desired_date=$1

# remove date option so remaining options can be passed transparently to git
shift

day_before=$(date -j -v-1d -f "%Y-%m-%d" "$desired_date" "+%Y-%m-%d")
day_after=$(date -j -v+1d -f "%Y-%m-%d" "$desired_date" "+%Y-%m-%d")

git log --after="$day_before" --before="$day_after" $@

The script is pretty straightforward but I'll draw special attention to the use of shift. This allows us to pass additional options to our command that get passed along to git log. So if you want the patch view with short stats, you're in luck: what-shipped-on 2018-11-23 -p --shortstat

May your answers always be clear and your fixes trivial.

My goofy face

Hi, I'm Jeffrey Chupp.
I solve problems, often with code.