Skip to content

Instantly share code, notes, and snippets.

@carlossless
Created November 24, 2015 09:29
Show Gist options
  • Save carlossless/0e79edc23fb48f9e8c7e to your computer and use it in GitHub Desktop.
Save carlossless/0e79edc23fb48f9e8c7e to your computer and use it in GitHub Desktop.
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