8yulhw
Last Updated: June 07, 2018
·
9
· psauxf
0 lxzqprchkz902ubp0jmwppchevpx2u6ppyuwpp3zbkbm1ha1jme4j1vrqr1t7wfxkysoyq1cn67q

easy CHANGELOG.md maker

Put this in a file

#!/bin/bash

if [ "$#" -ne 2 ]; then
    printf "Usage: $0 TAG1 TAG2RELEASE\n"
    exit 1
fi
OLD__=$1
RELEASE__=$2
_FROM_TO_=$OLD__...$RELEASE__
touch CHANGELOG.md
_URL_=$(git ls-remote --get-url | sed -e "s/^git@/https\:\/\//g" -e "s/\.git//g")

grep -A 1 -nE '^CHANGELOG$' CHANGELOG.md | grep -q '=========' || printf 'CHANGELOG\n=========\n\n' >> CHANGELOG.md
_INSERT_FROM_=$(grep -nE '^CHANGELOG$' CHANGELOG.md | awk -F: '{print ($1 + 2);}')
_TODAY_=$(date +%Y-%m-%d)

grep "# $RELEASE__ \/ $_TODAY_" CHANGELOG.md
if [ $? -ne 0 ]; then 
  _INFO_="# $RELEASE__ / $_TODAY_\n"
  sed -i "$_INSERT_FROM_ a $_INFO_ " CHANGELOG.md
  _COMMITS_=$(git log $_FROM_TO --decorate=auto --no-merges --no-renames --pretty=format:"*[view]($_URL_/commit/%H) %s\n" --reverse | cat | tr -d '\n')
  sed -i "$(($_INSERT_FROM_ + 1 )) a $_COMMITS_" CHANGELOG.md
  printf "CHANGELOG.md  updated\n"
else
  printf "CHANGELOG.md already updated\n"
fi

Save it and chmod +x

Now run it.

Screen Shot 2018-06-07 at 9.24.26 AM.png

Say Thanks
Respond
Filed Under