Created
November 27, 2015 11:57
-
-
Save mgor/4ff5a8243200b48acb42 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
commit_message=$1 | |
commit_type=$2 | |
commit_hash=$3 | |
prefix="[commit prefix]" | |
heading=$(head -1 ${commit_message}) | |
if [ -z "${heading}" ] | |
then | |
sed -i "1s/^/${prefix}: <insert heading here>\n/" ${commit_message} | |
elif [[ ${heading} != "${prefix}"* ]] | |
then | |
sed -i "1s/^.*/${prefix}: ${heading}/" ${commit_message} | |
fi | |
line_count=$(egrep -v "ChangeId|^#|^$" -c ${commit_message}) | |
if [ ${line_count} -lt 3 ] | |
then | |
sed -i '2 a<insert description here>\n' ${commit_message} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment