Skip to content

Instantly share code, notes, and snippets.

@ern
Last active October 7, 2019 19:18
Show Gist options
  • Save ern/856adcf93094be9afca46934332c81bd to your computer and use it in GitHub Desktop.
Save ern/856adcf93094be9afca46934332c81bd to your computer and use it in GitHub Desktop.
#!/bin/bash
##############################################################################
# This script output what paths have changed using a SHA Range
#
# Example usage:
#
# Author: Earle Nietzel
# Date: 8/21/2019
# License: http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
##############################################################################
GIT_CMD="git"
GREP_CMD="grep"
CUT_CMD="cut"
SORT_CMD="sort"
usage()
{
printf "Usage: %s [-s] <SHA start> [<SHA end>]\n" $0
}
# Set up options
while getopts "h:s" options; do
case $options in
h)
usage
exit 1
;;
s)
SHOW_CMD=1
;;
[?])
exit 1
;;
esac
done
if [ -n "$2" ]
then
SHA_END="$2"
else
SHA_END="HEAD"
fi
if [ -n "$1" ]
then
SHA_START=$1
else
usage
printf "Must supply the start SHA\n"
exit 1
fi
CMD="$GIT_CMD log --name-only --pretty=format: $SHA_START..$SHA_END | $GREP_CMD -v '^$' | $CUT_CMD -d '/' -f1 | $SORT_CMD -u"
if [ "$SHOW_CMD" ]
then
printf "%s\n" "$CMD"
else
eval "$CMD"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment