Skip to content

Instantly share code, notes, and snippets.

@labkey-tchad
Last active March 29, 2023 19:02
Show Gist options
  • Save labkey-tchad/99f53cf447ebe632d7b743aa26b81e6c to your computer and use it in GitHub Desktop.
Save labkey-tchad/99f53cf447ebe632d7b743aa26b81e6c to your computer and use it in GitHub Desktop.
function mddiff()
{
LEFT_REF=$1
RIGHT_REF=$2
NAME=$(basename ${PWD})
if [ -z "${LEFT_REF:-}" ] || [ -z "${RIGHT_REF:-}" ]; then
echo "Please specify the branches, tags, or commits to compare." >&2
echo " Usage: mddiff ref1 ref2" >&2
echo " Example: mddiff 21.11.0 origin/release21.11-SNAPSHOT" >&2
return 1
fi
if ! command -v hub > /dev/null; then
echo 'Error: GitHub command line tool is not installed. https://hub.github.com/' >&2
return 1
fi
BASE_URL=$(hub browse -u)
echo ''
echo "#### [${NAME}](${BASE_URL}/compare/$(echo ${LEFT_REF} | sed 's/origin\///')...$(echo ${RIGHT_REF} | sed 's/origin\///'))"
git log ${LEFT_REF}..${RIGHT_REF} --no-merges --decorate --decorate-refs=refs/tags/ --pretty=format:" -%d [%s]($BASE_URL/commit/%H)" --topo-order
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment