Skip to content

Instantly share code, notes, and snippets.

@hafs-r
Last active July 4, 2020 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hafs-r/6c2705df16cab153ae02149f6cc4b7f1 to your computer and use it in GitHub Desktop.
Save hafs-r/6c2705df16cab153ae02149f6cc4b7f1 to your computer and use it in GitHub Desktop.
# bash script to generate release not based on commit message
# commit message include the trello task id prefix as 'trello:<id>'
=$(git log --pretty="format: %s" master..HEAD | sed -e 's/$/|/'| tr -d '\n')
```
The complete **release_notes_generator.sh** as below
```bash
#! /bin/bash
# fetch all and ignore the output.
# Fetch all is needed to get the master branch needed in the git log command.
git fetch --all > /dev/null 2>&1
# Because we are in a different branch of the master, we need to track the master
# branch locally.
# Also ignore the output.
git branch --set-upstream master origin/master > /dev/null 2>&1
#fetch commit logs after last tag with given prefix
LOGS=$(git log --pretty="format: %s" master..HEAD | sed -e 's/$/|/'| tr -d '\n')
RELEASE_NOTE=''
OTHER_NOTE=''
O=$IFS
IFS='|'
shopt -s nocasematch
for i in ${LOGS[@]}
do
if [[ $i == *"trello:"* ]]; then
trelloid=$(echo $i | cut -d':' -f 2 | cut -d' ' -f 1 )
prefix="https://trello.com/c/"
temp="${prefix}""${trelloid}\n"
RELEASE_NOTE=$RELEASE_NOTE$temp
else
OTHER_NOTE=$OTHER_NOTE$"$i, "
fi
done
IFS=$O
if [[ ! -z "$OTHER_NOTE" ]]; then
other="Other notes."
RELEASE_NOTE=$RELEASE_NOTE$other
fi
if [[ -z "$RELEASE_NOTE" ]]; then
RELEASE_NOTE="No release notes generated"
fi
echo "$RELEASE_NOTE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment