Last active
May 11, 2016 06:52
-
-
Save anlcan/19997c91f6c1f94668faf1d89a65ce2f 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
#!/bin/bash | |
# set -e # fail if any commands fails | |
# check if issue has the right format, if it fails, nothing will happen | |
ISSUE=`echo $1 | grep -io '[[:alpha:]]\+-[[:digit:]]\+'` | |
echo "using $ISSUE" | |
## check issue exists on jira | |
SHOW=`jira show $ISSUE` | |
[[ $SHOW == "Issue Does Not Exist" ]] && echo "no issue found" && exit 0; | |
## show issue | |
echo "$SHOW" | |
if [ `git branch --list $ISSUE` ] | |
then | |
echo "Branch name $ISSUE already exists." | |
git checkout $ISSUE | |
exit 0 | |
fi | |
# create and checkout a branch named after the issue (ie JIRA-1) | |
git checkout -b $ISSUE | |
# assign issue to me | |
jira assign $ISSUE | |
# start working on issue (not that you might get bad transition warning) | |
jira start $ISSUE |
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
#!/bin/bash | |
# get current branch name | |
BRANCH=`git symbolic-ref --short -q HEAD` | |
ISSUE=$BRANCH | |
echo $ISSUE | |
# assume the branch name is also the issue name | |
SUMMARY=`jira show -o summary $ISSUE` | |
echo $SUMMARY | |
# a last commit with summary | |
git commit -am "$SUMMARY" | |
# push to origin, grep the pull-request url | |
git push -u --verbose origin HEAD 2> tmp_file | |
# grep pull request url from push command output | |
PR_URL=`grep -io 'https://bitbucket.org/.*' tmp_file` | |
rm tmp_file | |
echo "PR URL: $PR_URL" | |
# mark issue done | |
jira done $ISSUE | |
# magic : http://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash | |
if [ -z ${PR_URL} ]; then echo "no pull request url found"; else open $PR_URL; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment