jb is a simple Git script that automatically creates and switches to a branch based on a JIRA issue. It uses the JIRA API to fetch the issue number and title, converting it into a suitable Git branch name.
-
Compile the binary:
go build -o git-jb . -
Copy the
git-jbbinary to a directory in yourPATH, for example:cp git-jb /usr/local/bin/ chmod +x /usr/local/bin/git-jb
-
Set the required environment variables for JIRA authentication:
export JIRA_USERNAME="your_username" export JIRA_TOKEN="your_token" export JIRA_URL="https://your-jira-instance.com"
In a Git repository, run:
git jb ISSUE-123Where ISSUE-123 is the JIRA issue number. The script:
- Fetches issue details via the JIRA API.
- Creates a Git branch named
ISSUE-123-issue-title. - If the branch exists, it switches to it.
- If the branch does not exist, it creates and switches to it.
- Git
- API access to JIRA
- Environment variables
JIRA_USERNAME,JIRA_TOKEN,JIRA_URL go-jiralibrary
If a JIRA issue exists:
ISSUE-123: Fix bug in authentication
Then running:
git jb ISSUE-123Will create or switch to the branch:
ISSUE-123-fix-bug-in-authentication
MIT