Created
March 2, 2015 15:24
-
-
Save sveinungkb/5c49bea66374cab0975e to your computer and use it in GitHub Desktop.
Simple bash script to compact and add markdown links to any jira issues or git PR references
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 | |
# Use this script to create markdowned release notes based on a previous point in git history, e.g. for HockeyApp uploads from Jenkins/Team City | |
# Store current reference with git log --pretty=format:'%H' -n 1 > git-reference and pass as first parameter to this script | |
# Usage: record-history <git sha in the past> | |
PREVIOUS=$1 | |
CURRENT=$(git log --pretty=format:'%H' -n 1) | |
JIRA_BASE='https:\/\/your.jira.com\/browse\/' | |
GIT_BASE='https:\/\/github.com\/organization\/repository\/pull\/' | |
# Change AA to your JIRA issue prefix | |
HISTORY=$(git log --pretty=";%s (%cn)" $PREVIOUS..$CURRENT | grep 'AA-\d*\|#\d*') | |
add_links() { | |
# Change AA to your JIRA issue prefix | |
echo $1 | sed "s/.*\(AA-[0-9]*\)\(.*\)/[\1]($JIRA_BASE\1)\2/" | sed "s/\(.*\)\(#[0-9]*\)\(.*\)/\1[\2]($GIT_BASE\2)\3/" | |
} | |
while IFS=';' read -ra ADDR; do | |
for i in "${ADDR[@]}"; do | |
if ! [[ "$i" = "" ]]; then | |
add_links "$i" | |
fi | |
done | |
done <<< "$HISTORY" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment