Skip to content

Instantly share code, notes, and snippets.

@hugosenari
Last active January 11, 2019 17:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugosenari/9976454 to your computer and use it in GitHub Desktop.
Save hugosenari/9976454 to your computer and use it in GitHub Desktop.
git + jira(atlassian) + stash(atlassian)
# 'BNAME' = current branch name
# 'BDESC' = current branch description
# return the name of current branch
bname = rev-parse --abbrev-ref HEAD
# get/set description for current branch
bdesc = "!f() { BNAME=`git bname`; if [ $# -gt "0" ]; then BNAME=$1; fi; if [ $# -lt "2" ]; then git config branches.$BNAME.description; else git config branches.$BNAME.description \"$2\"; fi; }; f"
# create new branch with $1 as BNAME and $2 as BDESC, push to vp
bissue = "!f() { git checkout -b $1; git config branches.$1.description \"$2\"; git push -u vp $1; }; f"
# commit with BNAME - BDESC before message
cbissue = "!f() { MSG=$1; shift; git commit -m \"issue: `git bname` - `git bdesc`; commit: $MSG\" $*; }; f"
# get jira issue summary
issue = "!f() { jira show -o summary $1; }; f"
# create pull request
pull-request = !sh -c 'stash pull-request $0'
# pull-request = !sh -c 'stash pull-request $0 --title \"`git bname` - `git bdesc`\"'
# https://bitbucket.org/atlassian/stash-command-line-tools/issue/10/pull-request-set-title-description
# Create a branch using $1(ISSUE-ID) as BNAME and ISSUE-SUMMARY as BDESC
start = "!f() { BDESC=`git issue $1`; git bissue $1 \"$BDESC\"; }; f"
stop = "!f() { TOBNAME=master; if [ $# -gt "0" ]; then TOBNAME=$1; fi; git push; COMMENT=`git pull-request $TOBNAME`; BNAME=`git bname`; jira comment $BNAME \"$COMMENT\"; echo $COMMENT; }; f"

git + jira + stash

My shortcuts to use with git, jira and stash

Dependencies:

Install and configure this:

How To:

Start working on jira issue:

git start ISSUE-ID

This will:

  • Create a local branch with ISSUE-ID as name, ISSUE-SUMMARY as branch description
  • Change to this new branch
  • Create a remote (origin) branch with same name

Make your commits using:

git cbissue "BLA THIS IS MY COMMIT"

This will:

  • git commit -m "ISSUE-ID - ISSUE-SUMMARY - commit: BLA THIS IS MY COMMIT"

Stop working on issue:

git stop

This will:

  • Push to origin
  • Create a pull request
  • Comment on jira with pull-request URL

TODO:

Current version don't change issue to working. That can be done adding to start, stop

jira start $BNAME
jira stop $BNAME

Also add option to close issue with stop

@hugosenari
Copy link
Author

I think isn't hard convert to other tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment