This is a small git command to help with a Jira workflow. It will assist in creating branches based off ticket ID's as well as starting pull-requests. A few other useful things it can do are open the current branch's ticket and copy its URL.
Since we're using HTTParty and basic-auth you must have a username/password for your jira account. Google authentication will not work. To reset/create a password for your Jira account visit https://YOURDOMAIN.atlassian.net/login/forgot and reset your password.
Clone this repo locally:
git clone https://github.com/robhurring/git-jira.git
Install dependencies:
bundle install
Install the gem:
rake install
Configure your Jira authentication (currently only .netrc/basic auth):
echo "machine DOMAIN.atlassian.net login user.name password s3cr1t" >> ~/.netrc
chmod 600 ~/.netrc
git jira config
Theres a few things you can configure using the format git jira config -s KEY=VALUE
Running this command will create a file at ~/.git-jira/config.yml
that you can modify as well.
This is your subdomain on the jira site
This is used to prefix associated repos in the pull-requests. This can be your username or organization name.
When generating a pull-request walk all directories in repo_search_paths
and see if the git repository is using the same branch name. If the branches match, it will be pulled into the pull-request as an 'Associated Repo'. Separate multiple paths with a ","
Example: git jira config -s repo_search_paths=~/Sites/apps,~/Sites/gems
If you want to override any templates, place them in this folder. There is only the pull_request
template currently.
Example: git jira config -s templates_path=~/.my-templates
When creating a branch, use upto chars from the summary.
git jira branch <TICKET ID> [DESCRIPTION]
Pass in a given ticket id to start a new branch in the format "TICKET_FIRST_X_CHARS_OF_TICKET_SUMMARY"
If you pass in a description as the second argument it will use that as the description, otherwise it will fetch the ticket through the API and use the summary line.
Must be on a jira branch
git jira info
If you are on a jira branch (one starting with FY-####) this will grab the ticket through the API and spit out some basic details about it; things like summary, description, asignee, reporter, reviewer, status, etc.
Must be on a jira branch
git jira open
This will open the current branch's ticket in your browser
Must be on a jira branch
git jira pull-request
git jira pull-request --create
*Uses the hub
command to open the pull-request`
This will lookup a bunch of details about your branch and produce a pull-request template with the following things:
- The formatted title "TICKET#: Summary of ticket"
- A link to the ticket in the description
- Any associated apps/gems (see config section for more)
- The code reviewer
You can create your own pull-request template by updating the config setting templates_path
(see config section)
Templates will be searched for in git jira config -g templates_path
Name: pull-request *Template: *
/cc %{reviewer}
%{ticket_link}
### Associated
%{associated_repos}
### Summary
### Testing
The variables are:
reviewer
: The ticket's code reviewer's username (no github user mapping)ticket_link
: A link to the ticketassociated_repos
: Any repo inrepo_search_paths
that is using the same branch. (See config section)
- Fork it ( https://github.com/[my-github-username]/git-jira/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request