Giter VIP home page Giter VIP logo

git-jira-branch's Introduction

git-jira-branch - Manage branches for your Jira tickets

git-jira-branch Logo

Creates feature branches based on your Jira tickets type and description.

$ git jira-branch create MYAPP-1234
> Successfully created branch: 'feat/MYAPP-1234-sluggified-description-used-as-branchname'

Usage

Since this command starts with git- all commands can be run via git-jira-branch or as a git subcommand with git jira-branch.

Due to a limitation in the awesome cli library used, all options must be passed before the jira ticket key argument.

Create a new branch from your current HEAD

Using the default JIRA_KEY_PREFIX

git-jira-branch create 1324

Or fully specified:

git-jira-branch create MYAPP-1234

Create a new branch based on some other revision

To create a new branch based on your master branch:

git-jira-branch create -b master MYAPP-1234

Reset an already existing branch

Pass the -r|--reset flag to reset an already existing branch to the current HEAD or the specified base revision (with -b)

git-jira-branch create -r MYAPP-1234

Switch to an already existing branch that is associated with a Jira ticket

To switch to an already existing branch that is associated with a Jira ticket you can use the switch command.

git-jira-branch switch MYAPP-1234

Open tickets in your browser

  1. For the current branch:
    $ git jira-branch open
    > Opening ticket url 'https://gcjb.atlassian.net/browse/GCJB-164' in your default browser...
  2. For a given ticket:
    $ git jira-branch open GCJB-1234
    > Opening ticket url 'https://gcjb.atlassian.net/browse/GCJB-1234' in your default browser...

Show ticket info on your terminal

The info command shows the information for ticket nicely rendered for consumtpion in the terminal.

By default info is show for the ticket associated with the current branch. Alternatively a ticket key can be passed as an argument to show info for that ticket.

$ git jira-branch info

Will create output like this:

GCJB-1 - Ticket summary
Task | Status: To Do | Creator: Alexander Pankoff | Assignee: Alexander Pankoff

Long lines in the description of the ticket are wrapped to fit a line width of
80 characters to make it easier to read.

List branches associated with jira tickets

$ git jira-branch list
> * feat/GCJB-1-e2e-test-ticket-with-a-fancy-summary
>   feat/GCJB-2-another-ticket-that-looks-like-its-associated-with-a-jira-ticket

wizard mode

Use the --wizard option to enter wizard mode. This will prompt you for the Jira ticket key and additional options and build the appropriate command line for you.

git-jira-branch --wizard

Setup

Install

The cli can be installed from npm. It assumes you have git installed on your system and the git command to be available on your $PATH.

npm i -g git-jira-branch

Configuration

For Jira Cloud

  1. Create a Jira API Token See Jira Docs
  2. Add the created API Token, your login email, the base url of your Jira instance and optionally a default Jira key prefix to your environment. For example in your .bashrc or .zshrc:
    export JIRA_USER_EMAIL="YOUR_JIRA_LOGIN_EMAIL"
    export JIRA_API_TOKEN="YOUR_API_TOKEN"
    export JIRA_API_URL="https://jira.mycompany.com"
    export JIRA_KEY_PREFIX="MYAPP"

For Jira Data Center

  1. Create a Jira PAT (Personal Access Token) See Jira Docs
  2. Add the created Jira PAT, the base url of your Jira instance and optionally a default Jira key prefix to your environment. For example in your .bashrc or .zshrc:
    export JIRA_PAT="YOUR_PERSONAL_ACCESS_TOKEN"
    export JIRA_API_URL="https://jira.mycompany.com"
    export JIRA_KEY_PREFIX="MYAPP"

Setup shell completions

The cli can generate shell completion scripts for bash,zsh and fish. To generate and print the script for your shell run:

git-jira-branch --completions (bash|zsh|fish)

To install the completions for your shell, run the above command and pipe the output to a file and source it in your shell config.

E.g. for bash:

git-jira-branch --completions bash > ~/.git-jira-branch-bash-completions
echo "source \$HOME/.git-jira-branch-bash-completions" >> ~/.bashrc
source ~/.bashrc

Technologies used

This project was started as an excuse to explore the Effect ecosystem and was written with only @effect/* packages as it's runtime dependencies. It uses:

Package Usage
effect The core effect system and runtime.
@effect/cli Command line handling and option parsing.
The wizard mode and --completions option are automatically provided by this lib.
@effect/platform For its http client.
@effect/platform-node For its shell command executor.

It uses the Jira API to fetch the details for a ticket and calls out directly to git for branch creation.

Tests were written using vitest. The testsuite can be run using npm run test.

License

The code in this repository is licensed under the MIT License. Please note that the MIT License applies only to the code in this repository and not to any other assets, especially not the Logo.

git-jira-branch's People

Contributors

ccntrq avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

Jan Stümmel avatar Marco Schweizer avatar Marcel Czaplinski avatar Ehsan A avatar  avatar Marcelo Dias avatar Artyom Arzamasov avatar Adrian avatar Ricardo Valero de la Rosa avatar

Watchers

 avatar  avatar

Forkers

zodimo

git-jira-branch's Issues

Switch to existing branches

It would be nice if the command would switch to an existing branch instead of throwing an error in that case.
An option to reset an already existing branch (similar to git checkout -B) could also be useful.

Parse JiraKey input

The jiraKey arg for all commands using it should be parsed into a FullKey | ShortKey union. Invalid values should be rejected with a meaningful error message

Upstream for branches created from a basebranch (`-b`) doesn't match branch name

This leads to the following error when trying to push these branches for the first time:

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:v2

To push to the branch of the same name on the remote, use

    git push origin HEAD

To choose either option permanently, see push.default in 'git help config'.

The upstream should be set appropriately when the branch is created.

Open web browser with overview of the ticket or the current branch

It should be possible to open a browser directly or generate a url to click on.

Without arguments the url should be genrated for the current branch. With arguments for arbitrary tickets

E.g.

git create-jira-branch --open opens overview for the ticket of the current branch

git create-jira-branch --open MYAPP-1234 opens overview for ticket MYAPP-1234

Add cleanup feature

There should be a subcommand/option to remove branches for tickets that are DONE.

  • Delete only merged branches
  • -f|--force also deletes unmerged branches

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.