Skip to content

Instantly share code, notes, and snippets.

@misterbrownlee
Created June 2, 2018 03:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterbrownlee/e0fafdd3f23e23d02b9582a2d0abeab7 to your computer and use it in GitHub Desktop.
Save misterbrownlee/e0fafdd3f23e23d02b9582a2d0abeab7 to your computer and use it in GitHub Desktop.
OHAI CHANGLOG
#!/usr/bin/env bash
# this is used to make the git log command less blorky
GH_URL_BASE='http://github.com/misterbrownlee/stupidstuff/'
# tell folks wassup
echo -e "Let's make a changelog!\n"
# get the current end of the commit range
MEOW=`git describe --abbrev=0 | cut -c 2-`
# get the low end of the commit range
echo "Adding new commits will span from a past version to the current version"
read -p 'Enter past version for generting the list of commits: v' LAST_VERSION
# make room for writing a new changelog file
mv CHANGELOG.md CHANGELOG.md.temp
# write some boilerplate into a new changelog file and append more things
printf '# OHAI Changelog\n\n' > CHANGELOG.md
printf '# v'$MEOW' \n' >> CHANGELOG.md
printf 'Published as `stupid-stuff@'$MEOW'`\n\n' >> CHANGELOG.md
printf '### Release Notes\n\n<WRITE NOTES HERE>\n\n' >> CHANGELOG.md
printf '### Commits\n' >> CHANGELOG.md
# now call git log with the version range and append that into the file
git log v$LAST_VERSION...HEAD^ \
--pretty=format:"- %s ([%h]($GH_URL_BASE%H))" \
>> CHANGELOG.md
# more newlines is need for format helping
printf '\n\n' >> CHANGELOG.md
# last we append content of the orginal changelog file into the new file
# minus the header...
# fancy, right?
tail -n +2 "CHANGELOG.md.temp" >> CHANGELOG.md
# clean up the temp file
rm CHANGELOG.md.temp
# tada!
echo 'DONE... commit the new changelog after adding TL;DR release notes'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment