-
-
Save cm0s/08f7a2846c58ca03b7de6ff96fb91f74 to your computer and use it in GitHub Desktop.
prefixes commit message with path of changed files. useful in mono-repo setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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