Skip to content

Instantly share code, notes, and snippets.

@fgeller
Created March 21, 2017 01:20
Show Gist options
  • Save fgeller/aabf703dd47d772403953f4389526499 to your computer and use it in GitHub Desktop.
Save fgeller/aabf703dd47d772403953f4389526499 to your computer and use it in GitHub Desktop.
prefixes commit message with path of changed files. useful in mono-repo setup
#!/bin/sh
prefixes=$(git diff --cached --name-only | while read f ; do echo "${f%/*}" ; done | sort | uniq)
prefixes_count=$(echo $prefixes | wc -l)
if [ "$prefixes_count" -eq "1" ]; then
sed -i "1s;^;$prefixes: \n;" "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment