Created
April 11, 2020 02:17
-
-
Save pascencio/52e9b8519aa8905551b5268c1e54e056 to your computer and use it in GitHub Desktop.
Change Log Markdown
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 | |
gitlab_repo_url=$( git remote get-url origin | sed -rn 's/(.*)\.git/\1/p' ) | |
gitlab_commit_path="/-/commit/" | |
git_tag=$( git describe ) | |
changelog_markdown="CHANGELOG.md" | |
changelog_markdown_tmp="CHANGELOG.md.tmp" | |
to_long_commit_type(){ | |
short_commit_type="$1" | |
case $short_commit_type in | |
FEA) | |
echo "Feature" | |
esac | |
} | |
if [ -f ${changelog_markdown} ]; | |
then | |
mv ${changelog_markdown} ${changelog_markdown_tmp} | |
fi | |
echo "# Change Log" > ${changelog_markdown} | |
echo "" >> ${changelog_markdown} | |
echo "## Versión ${git_tag}" >> ${changelog_markdown} | |
echo "" >> ${changelog_markdown} | |
git log --pretty="%h|%H|%cn|%ce|%s" | grep -vE '\[(GIT|UNS)\]' | sed -rn 's/(.*)\[(.*)\]:.(.*)/\1\2|\3/p' | while read -r line ; do | |
short_hash=$( echo "$line" | cut -d'|' -f1 ) | |
full_hash=$( echo "$line" | cut -d'|' -f2 ) | |
short_commit_type=$( echo "$line" | cut -d'|' -f5 ) | |
commit_type=$( to_long_commit_type ${short_commit_type}) | |
commiter_name=$( echo "$line" | cut -d'|' -f3 ) | |
commiter_email=$( echo "$line" | cut -d'|' -f4 ) | |
commit_message=$( echo "$line" | cut -d'|' -f6 ) | |
echo " - **${commit_type}**: ${commit_message} ([${commiter_name}](mailto:${commiter_email}) en [#${short_hash}](${gitlab_repo_url}${gitlab_commit_path}${full_hash}))" >> ${changelog_markdown} | |
done | |
if [ -f ${changelog_markdown_tmp} ]; | |
then | |
cat ${changelog_markdown_tmp} | grep -vE 'Change Log' >> ${changelog_markdown} | |
rm -f ${changelog_markdown_tmp} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment