Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A script to parse a given range of the current git repo log, find Jira issue Ids and print out links to them
#!/bin/bash
COMMIT_RANGE=$TRAVIS_COMMIT_RANGE
JIRA_ISSUE_PREFIX="VI-"
JIRA_ISSUE_BASE_URL="https://mycompany.atlassian.net/browse/"
if [ -z "$COMMIT_RANGE" ]; then >&2 echo "Commit Range is Empty. Exiting."; exit 0; fi
GIT_LOG=`git log --pretty=format:'%h %ad %s | %an' --date=short "$COMMIT_RANGE" | grep -v Merge | sed -E 's/.{7} (.*)/\1/g'`
JIRA_ISSUES=`echo "$GIT_LOG" | grep -E "$JIRA_ISSUE_PREFIX\d+" | sed -E "s/.*($JIRA_ISSUE_PREFIX[0-9]+).*/\1/g" | sort | uniq | awk -v prefix=$JIRA_ISSUE_BASE_URL '{print prefix $0}'`
echo "Affected Issues:"
echo "$JIRA_ISSUES"
echo ""
echo "Commit Log:"
echo "$GIT_LOG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.