Last active
July 4, 2020 20:05
-
-
Save hafs-r/6c2705df16cab153ae02149f6cc4b7f1 to your computer and use it in GitHub Desktop.
This file contains 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
# 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