jgit
v0.12.0
Published
Utility functions for Jira and Git
Downloads
545
Readme
jgit
Pronounced /dʒeɪ ɡɛt/
A Jira and Git workflow management tool with a CLI interface
jgit- Purpose
- Who This Tool is For
- Why I created this
- Comparison with other tools
- Setup
- Development Setup
- Debugging
- Release Process
- Roadmap
- Usage
- Commands
Purpose
jgit allows you to easily:
- Create standardized git branch names and conventional commit messages from Jira issues
- Search and open changeset requests (i.e., Pull Requests and Merge Requests) that are associated to specific Jira issues
- Query changeset requests for files changed in relation to specific Jira Issues
- If you use neovim and grapple.nvim, you can use this feature to easily pick back up where you started when working on a Jira ticket, by getting a list of file paths that you were working with, and paste that list of file paths into the
grapple.nvimbuffer.
- If you use neovim and grapple.nvim, you can use this feature to easily pick back up where you started when working on a Jira ticket, by getting a list of file paths that you were working with, and paste that list of file paths into the
- Generate Slack-style messages referencing changeset requests created to address Jira issues
Who This Tool is For
Although there are integrations between Jira and GitHub such as GitHub for Atlassian, these require set up, and sometimes your organization may not do this. This is where jgit is useful, because it acts as an "unofficial" integration tool that makes it easier to work with Jira issues and remote git repositories until (hopefully) the official integration is set up within your organization.
Why I created this
I made this tool because I'm lazy.
Specifically, I wanted:
- A unified and simple interface for interfacing with whatever remote git repository is used within a repository, without having to alternate between using gh and glab, and re-learn the specific syntax of each to do the same tasks.
- A standardized way of creating git branch names and commit messages that did not require thinking on my end. While I appreciate the ability in Jira to automatically create git branch directly from a Jira issue, this integration requires set up on behalf of your company, and if your company does not have that set up, you are stuck with the old way of creating git branch names.
- An easy way to share with coworkers when I had created PRs/MRs for a Jira issue, in a nicely formatted markdown message to post in Slack.
Comparison with other tools
gh CLI
To search for all PRs related to a Jira issue and open the results in a web browser:
gh pr list --search "TEAM-123" --state all --webglab CLI
To search for merged MRs related to a Jira issue:
glab mr list --search "TEAM-123" --mergedTo search for open MRs related to a Jira issue:
glab mr list --search "TEAM-123"NOTE: You cannot get a list of all MRs that reference a Jira issue in the title regardless of their state using glab
NOTE: You cannot automatically open all found MRs that reference a Jira issue in their title using glab
jgit
Compared to:
jg prs TEAM-123 --webSetup
GitHub API Auth
You will need to export a GitHub OAuth Token to authenticate with the GitHub API.
GitHub Personal Access Token Documentation
export JGIT_GITHUB_OAUTH_TOKEN="YOUR_GITHUB_OAUTH_TOKEN"GitLab API Auth
You will need to export a GitLab OAuth Token to authenticate with the GitLab API.
GitLab Personal Access Token Documentation
export JGIT_GITLAB_HOSTNAME="YOUR_GITLAB_HOSTNAME"
export JGIT_GITLAB_OAUTH_TOKEN="YOUR_GITLAB_OAUTH_TOKEN"Codeberg API Auth
You will need to export a GitLab OAuth Token to authenticate with the GitLab API.
Codeberg Personal Access Token Documentation
export JGIT_CODEBERG_OAUTH_TOKEN="YOUR_GITLAB_OAUTH_TOKEN"Jira API Auth
You will need the following env vars set in your shell to authenticate with the Jira API:
export JGIT_JIRA_HOSTNAME="https://jira.example.com"
export JGIT_JIRA_API_TOKEN="YOUR_JIRA_API_TOKEN"
export JGIT_JIRA_API_EMAIL="YOUR_JIRA_EMAIL"Development Setup
git clone https://github.com/Drew-Daniels/jg.git
cd jg || exitMajority of users:
pnpm iIf using nix+direnv:
direnv allow .Debugging
To help debug a failing command, prepend DEBUG=<logger-name> to the command you're having issues with.
The following logger names are valid:
httpconfig
DEBUG=http,config jg related TEAM-123Release Process
- Update the version with:
pnpm version <patch|minor|major> - Create the distributable output with:
pnpm run build - Commit and push any updates if necessary
- Publish the latest version of the package:
pnpm publish
Roadmap
- [ ] Enable users to specifically search only merged/open/closed changeset requests related to an issue when using
changesetssub-command:--merged,--open,--closed - [ ] Allow users to specify multiple jira tickets as arguments for commands:
changesetschanged
- [ ] Enable searching through changeset request "body" data as well, not just titles to turn up more results that might be tangentially related to a given jira issue
- [ ] Look into modifying (or adding another command) the
ccsubcommand such that it also squashes all commits on a branch and sets the commit message to the conventional commit message - [ ] Add a
doctorsubcommand to check for configuration issues - [ ] Replace
mochatest runner with native NodeJS test-runner - [ ] Enable code coverage using builtin NodeJS coverage tool
- [ ] Enable Codeberg backend
- [ ] Look into creating a Codeberg API client using Codeberg's swagger documentation, and a code generation tool
- [ ] Implement testing similar to how the
twilioCLI does it:- https://github.com/twilio/twilio-cli
- https://github.com/twilio/twilio-cli-test
- [ ] Enable users to get specific changeset request by index, instead of just first and last (Ex.,
--second,--number=2, .etc.)- Applies to
changesets
- Applies to
- [ ] Allow for more flexible Jira Issue parsing logic by using
dot-propand user configuration to map Jira Issue fields to Conventional Commit pieces (type, scope, description, etc.) - [ ] Add
--treeoption tochangedsubcommand to display changed files in a filetree format- Using something like
to-path-tree&object-treeifyto parse an array of filepaths and transform it into a tree format
- Using something like
- [ ] Add
--tableoption tochangesetssubcommand to display all changeset requests in a table format- Using something like
tty-tableorcliuito render the table itself
- Using something like
Usage
$ npm install -g jgit
$ jg COMMAND
running command...
$ jg (--version)
jgit/0.12.0 darwin-arm64 node-v24.4.1
$ jg --help [COMMAND]
USAGE
$ jg COMMAND
...Commands
jg autocomplete [SHELL]jg bname ISSUEKEYjg cc ISSUEKEYjg changed ISSUEKEYjg changesets ISSUEKEYjg help [COMMAND]jg mrs ISSUEKEYjg notify ISSUEKEYjg pluginsjg plugins add PLUGINjg plugins:inspect PLUGIN...jg plugins install PLUGINjg plugins link PATHjg plugins remove [PLUGIN]jg plugins resetjg plugins uninstall [PLUGIN]jg plugins unlink [PLUGIN]jg plugins updatejg print-configjg prs ISSUEKEYjg url ISSUEKEY
jg autocomplete [SHELL]
Display autocomplete installation instructions.
USAGE
$ jg autocomplete [SHELL] [-r]
ARGUMENTS
SHELL (zsh|bash|powershell) Shell type
FLAGS
-r, --refresh-cache Refresh cache (ignores displaying instructions)
DESCRIPTION
Display autocomplete installation instructions.
EXAMPLES
$ jg autocomplete
$ jg autocomplete bash
$ jg autocomplete zsh
$ jg autocomplete powershell
$ jg autocomplete --refresh-cacheSee code: @oclif/plugin-autocomplete
jg bname ISSUEKEY
Generates a Git branch name from a Jira Issue Key
USAGE
$ jg bname ISSUEKEY [--json] [-h] [-q -c]
ARGUMENTS
ISSUEKEY Jira Issue Key
FLAGS
-c, --clipboard Copy to clipboard
-h, --help Show help
-q, --quiet Suppress output
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ jg bname
$ jg bname --clipboard
$ jg bname --clipboard --quiet
$ jg bname --jsonjg cc ISSUEKEY
Generates a Conventional Commit Message from a Jira Issue Key
USAGE
$ jg cc ISSUEKEY [--json] [-h] [-q -c]
ARGUMENTS
ISSUEKEY Jira Issue Key
FLAGS
-c, --clipboard Copy to clipboard
-h, --help Show help
-q, --quiet Suppress output
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ jg cc
$ jg cc --clipboard
$ jg cc --clipboard --quiet
$ jg cc --jsonjg changed ISSUEKEY
Lists changed files for a given Jira Issue
USAGE
$ jg changed ISSUEKEY [--json] [-h] [-q -c] [-a | -d]
ARGUMENTS
ISSUEKEY Jira Issue Key
FLAGS
-a, --asc Sorts file paths in ascending order
-c, --clipboard Copy to clipboard
-d, --desc Sorts file paths in descending order
-h, --help Show help
-q, --quiet Suppress output
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ jg changedjg changesets ISSUEKEY
Returns URL(s) for changesets (PRs, MRs) related to a given issue
USAGE
$ jg changesets ISSUEKEY [--json] [-h] [-q -c] [-f | -l] [-w]
ARGUMENTS
ISSUEKEY Jira Issue Key
FLAGS
-c, --clipboard Copy to clipboard
-f, --first Get the first (earliest) changeset request (PR, MR) for an issue
-h, --help Show help
-l, --last Get the last (latest) changeset request (PR, MR) for an issue
-q, --quiet Suppress output
-w, --web Opens related changeset requests (PRs, MRs) for an issue in default web browser
GLOBAL FLAGS
--json Format output as json.
ALIASES
$ jg prs
$ jg mrs
EXAMPLES
$ jg changesets
$ jg changesets --first
$ jg changesets --last
$ jg changesets --first --web
FLAG DESCRIPTIONS
-f, --first Get the first (earliest) changeset request (PR, MR) for an issue
Fetches all changeset requests related to an issue, sorts them such that the earliest changeset request comes first,
and returns the URL to that changeset request
-l, --last Get the last (latest) changeset request (PR, MR) for an issue
Fetches all changeset requests related to an issue, sorts them such that the latest changeset request comes first,
and returns the URL to that changeset requestjg help [COMMAND]
Display help for jg.
USAGE
$ jg help [COMMAND...] [-n]
ARGUMENTS
COMMAND... Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
DESCRIPTION
Display help for jg.See code: @oclif/plugin-help
jg mrs ISSUEKEY
Returns URL(s) for changesets (PRs, MRs) related to a given issue
USAGE
$ jg mrs ISSUEKEY [--json] [-h] [-q -c] [-f | -l] [-w]
ARGUMENTS
ISSUEKEY Jira Issue Key
FLAGS
-c, --clipboard Copy to clipboard
-f, --first Get the first (earliest) changeset request (PR, MR) for an issue
-h, --help Show help
-l, --last Get the last (latest) changeset request (PR, MR) for an issue
-q, --quiet Suppress output
-w, --web Opens related changeset requests (PRs, MRs) for an issue in default web browser
GLOBAL FLAGS
--json Format output as json.
ALIASES
$ jg prs
$ jg mrs
EXAMPLES
$ jg mrs
$ jg mrs --first
$ jg mrs --last
$ jg mrs --first --web
FLAG DESCRIPTIONS
-f, --first Get the first (earliest) changeset request (PR, MR) for an issue
Fetches all changeset requests related to an issue, sorts them such that the earliest changeset request comes first,
and returns the URL to that changeset request
-l, --last Get the last (latest) changeset request (PR, MR) for an issue
Fetches all changeset requests related to an issue, sorts them such that the latest changeset request comes first,
and returns the URL to that changeset requestjg notify ISSUEKEY
Generates a Slack Message with a Link to a Jira Issue and corresponding changeset request link to notify others of a changeset request
USAGE
$ jg notify ISSUEKEY [--json] [-h] [-q -c] [-f | -l]
ARGUMENTS
ISSUEKEY Jira Issue Key
FLAGS
-c, --clipboard Copy to clipboard
-f, --first Get the first (earliest) changeset request (PR, MR) for an issue
-h, --help Show help
-l, --last Get the last (latest) changeset request (PR, MR) for an issue
-q, --quiet Suppress output
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ jg notify
$ jg notify --clipboard
$ jg notify --clipboard --quiet
$ jg notify --json
FLAG DESCRIPTIONS
-f, --first Get the first (earliest) changeset request (PR, MR) for an issue
Fetches all changeset requests related to an issue, sorts them such that the earliest changeset request comes first,
and returns a reference to the first sorted changeset request
-l, --last Get the last (latest) changeset request (PR, MR) for an issue
Fetches all changeset requests related to an issue, sorts them such that the latest changeset request comes first,
and returns a reference to the first sorted changeset requestjg plugins
List installed plugins.
USAGE
$ jg plugins [--json] [--core]
FLAGS
--core Show core plugins.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
List installed plugins.
EXAMPLES
$ jg pluginsSee code: @oclif/plugin-plugins
jg plugins add PLUGIN
Installs a plugin into jg.
USAGE
$ jg plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
ARGUMENTS
PLUGIN... Plugin to install.
FLAGS
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
-h, --help Show CLI help.
-s, --silent Silences npm output.
-v, --verbose Show verbose npm output.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Installs a plugin into jg.
Uses npm to install plugins.
Installation of a user-installed plugin will override a core plugin.
Use the JG_NPM_LOG_LEVEL environment variable to set the npm loglevel.
Use the JG_NPM_REGISTRY environment variable to set the npm registry.
ALIASES
$ jg plugins add
EXAMPLES
Install a plugin from npm registry.
$ jg plugins add myplugin
Install a plugin from a github url.
$ jg plugins add https://github.com/someuser/someplugin
Install a plugin from a github slug.
$ jg plugins add someuser/somepluginjg plugins:inspect PLUGIN...
Displays installation properties of a plugin.
USAGE
$ jg plugins inspect PLUGIN...
ARGUMENTS
PLUGIN... [default: .] Plugin to inspect.
FLAGS
-h, --help Show CLI help.
-v, --verbose
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Displays installation properties of a plugin.
EXAMPLES
$ jg plugins inspect mypluginSee code: @oclif/plugin-plugins
jg plugins install PLUGIN
Installs a plugin into jg.
USAGE
$ jg plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
ARGUMENTS
PLUGIN... Plugin to install.
FLAGS
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
-h, --help Show CLI help.
-s, --silent Silences npm output.
-v, --verbose Show verbose npm output.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Installs a plugin into jg.
Uses npm to install plugins.
Installation of a user-installed plugin will override a core plugin.
Use the JG_NPM_LOG_LEVEL environment variable to set the npm loglevel.
Use the JG_NPM_REGISTRY environment variable to set the npm registry.
ALIASES
$ jg plugins add
EXAMPLES
Install a plugin from npm registry.
$ jg plugins install myplugin
Install a plugin from a github url.
$ jg plugins install https://github.com/someuser/someplugin
Install a plugin from a github slug.
$ jg plugins install someuser/somepluginSee code: @oclif/plugin-plugins
jg plugins link PATH
Links a plugin into the CLI for development.
USAGE
$ jg plugins link PATH [-h] [--install] [-v]
ARGUMENTS
PATH [default: .] path to plugin
FLAGS
-h, --help Show CLI help.
-v, --verbose
--[no-]install Install dependencies after linking the plugin.
DESCRIPTION
Links a plugin into the CLI for development.
Installation of a linked plugin will override a user-installed or core plugin.
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
command will override the user-installed or core plugin implementation. This is useful for development work.
EXAMPLES
$ jg plugins link mypluginSee code: @oclif/plugin-plugins
jg plugins remove [PLUGIN]
Removes a plugin from the CLI.
USAGE
$ jg plugins remove [PLUGIN...] [-h] [-v]
ARGUMENTS
PLUGIN... plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ jg plugins unlink
$ jg plugins remove
EXAMPLES
$ jg plugins remove mypluginjg plugins reset
Remove all user-installed and linked plugins.
USAGE
$ jg plugins reset [--hard] [--reinstall]
FLAGS
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
--reinstall Reinstall all plugins after uninstalling.See code: @oclif/plugin-plugins
jg plugins uninstall [PLUGIN]
Removes a plugin from the CLI.
USAGE
$ jg plugins uninstall [PLUGIN...] [-h] [-v]
ARGUMENTS
PLUGIN... plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ jg plugins unlink
$ jg plugins remove
EXAMPLES
$ jg plugins uninstall mypluginSee code: @oclif/plugin-plugins
jg plugins unlink [PLUGIN]
Removes a plugin from the CLI.
USAGE
$ jg plugins unlink [PLUGIN...] [-h] [-v]
ARGUMENTS
PLUGIN... plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ jg plugins unlink
$ jg plugins remove
EXAMPLES
$ jg plugins unlink mypluginjg plugins update
Update installed plugins.
USAGE
$ jg plugins update [-h] [-v]
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Update installed plugins.See code: @oclif/plugin-plugins
jg print-config
Prints merged result of user and default configurations
USAGE
$ jg print-config [--json] [-h] [-q -c]
FLAGS
-c, --clipboard Copy to clipboard
-h, --help Show help
-q, --quiet Suppress output
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ jg print-config
$ jg print-config --clipboard
$ jg print-config --clipboard --quiet
$ jg print-config --jsonjg prs ISSUEKEY
Returns URL(s) for changesets (PRs, MRs) related to a given issue
USAGE
$ jg prs ISSUEKEY [--json] [-h] [-q -c] [-f | -l] [-w]
ARGUMENTS
ISSUEKEY Jira Issue Key
FLAGS
-c, --clipboard Copy to clipboard
-f, --first Get the first (earliest) changeset request (PR, MR) for an issue
-h, --help Show help
-l, --last Get the last (latest) changeset request (PR, MR) for an issue
-q, --quiet Suppress output
-w, --web Opens related changeset requests (PRs, MRs) for an issue in default web browser
GLOBAL FLAGS
--json Format output as json.
ALIASES
$ jg prs
$ jg mrs
EXAMPLES
$ jg prs
$ jg prs --first
$ jg prs --last
$ jg prs --first --web
FLAG DESCRIPTIONS
-f, --first Get the first (earliest) changeset request (PR, MR) for an issue
Fetches all changeset requests related to an issue, sorts them such that the earliest changeset request comes first,
and returns the URL to that changeset request
-l, --last Get the last (latest) changeset request (PR, MR) for an issue
Fetches all changeset requests related to an issue, sorts them such that the latest changeset request comes first,
and returns the URL to that changeset requestjg url ISSUEKEY
Returns a URL to a Jira Issue
USAGE
$ jg url ISSUEKEY [--json] [-h] [-q -c] [-m] [-w]
ARGUMENTS
ISSUEKEY Jira Issue Key
FLAGS
-c, --clipboard Copy to clipboard
-h, --help Show help
-m, --markdown Get Markdown Link to Jira Issue
-q, --quiet Suppress output
-w, --web Opens issue in default web browser
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ jg url
$ jg url --clipboard
$ jg url --clipboard --quiet
$ jg url --json