Skip to content

Instantly share code, notes, and snippets.

@mgor
Created November 27, 2015 11:57
Show Gist options
  • Save mgor/4ff5a8243200b48acb42 to your computer and use it in GitHub Desktop.
Save mgor/4ff5a8243200b48acb42 to your computer and use it in GitHub Desktop.
#!/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