Skip to main content

Create Git branches from Jira tickets

Project description

PyPI - Version

bfjira - Branch Management with JIRA Integration

bfjira (branch from Jira) is a command-line utility that simplifies the process of creating Git branches based on JIRA ticket information. It ensures that branch names are consistent and informative by incorporating the issue type and summary from the JIRA ticket.

Installation

The recommended way to install bfjira is via pip from PyPI:

pip install bfjira

Make sure you have pip installed and are using a virtual environment if necessary.

Usage

To use bfjira, you must have the following environment variables set:

  • JIRA_SERVER: Your JIRA server URL.
  • JIRA_EMAIL: The email address associated with your JIRA account.
  • JIRA_API_TOKEN: Your JIRA API token.

Instructions for creating a Jira API token can be found here

Optionally, you can set the JIRA_TICKET_PREFIX environment variable to use a default prefix other than "SRE" for ticket IDs that are entered without a prefix.

Basic Commands

  • Show version:

    bfjira --version
    
  • Show help message:

    bfjira --help
    
  • Create a branch for a JIRA ticket:

    bfjira --ticket SRE-1234
    

    If you only have the ticket number, bfjira will use the default prefix ("SRE" or whatever is set in JIRA_TICKET_PREFIX):

    bfjira -t 1234
    

Advanced Options

  • Set a custom issue type for the branch:

    bfjira -t 1234 --issue-type hotfix
    
  • Create a branch without setting the upstream:

    bfjira -t 1234 --no-upstream
    
  • Increase output verbosity (useful for debugging):

    bfjira -t 1234 --verbose
    
  • Optionally prevent transitioning the ticket to 'In Progress':

    By default, the script transitions the specified JIRA ticket to 'In Progress'. If you wish to create a branch for the ticket without changing its status, use the --no-progress flag. This is useful when you need to perform operations on the ticket without indicating that work has started.

    bfjira -t 1234 --no-progress
    
  • Handle uncommitted changes:

    If bfjira detects uncommitted changes (including untracked files) in your repository, it will prompt you before proceeding. You can choose to have the script automatically stash these changes. The stash will be automatically popped after the branch is successfully created and the JIRA ticket is transitioned. If you choose not to stash, the script will exit.

Versioning

bfjira follows Semantic Versioning (SemVer) for its releases:

  • MAJOR version (X.0.0) - Incompatible API changes
  • MINOR version (0.X.0) - New features in a backward-compatible manner
  • PATCH version (0.0.X) - Backward-compatible bug fixes

The versioning is automated through GitHub Actions, which:

  1. Detects the type of change (feature, fix, etc.) from commit messages
  2. Automatically increments the appropriate version number
  3. Creates a new release and publishes to PyPI

Troubleshooting

Common Issues

  1. JIRA Authentication Errors

    • Ensure your JIRA_API_TOKEN is valid and not expired
    • Verify your JIRA_EMAIL matches the account associated with the API token
    • Check that your JIRA account has the necessary permissions
  2. Branch Creation Issues

    • Make sure you're in a Git repository
    • Verify you have write permissions to the repository
    • Check that the branch name doesn't already exist
  3. Version Mismatches

    • If you encounter version-related issues, try updating to the latest version:
      pip install --upgrade bfjira
      

Getting Help

If you encounter issues not covered here:

  1. Check the GitHub Issues for similar problems
  2. Enable verbose output with --verbose flag for more detailed error messages
  3. Open a new issue with detailed information about your problem

Development

Setup

bfjira uses Poetry for dependency management and packaging. To set up the development environment:

  1. Install Poetry:

    curl -sSL https://install.python-poetry.org | python3 -
    
  2. Clone the repository:

    git clone https://github.com/nwhobart/bfjira.git
    cd bfjira
    
  3. Install dependencies:

    poetry install
    
  4. Activate the virtual environment:

    poetry shell
    

Running Tests

Run the test suite with:

poetry run pytest

Contributing

Contributions to bfjira are welcome! Please read the contributing guidelines before submitting pull requests.

License

bfjira is released under the GNU General Public License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bfjira-0.7.6.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bfjira-0.7.6-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file bfjira-0.7.6.tar.gz.

File metadata

  • Download URL: bfjira-0.7.6.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bfjira-0.7.6.tar.gz
Algorithm Hash digest
SHA256 cf67d7f6657d55162a5e511641afb4b77f8d0372df689cff7c628352388ed70d
MD5 9304a50a1fb88f2a4687bda26afd1b7f
BLAKE2b-256 e71089368ac2d77173b0d00b788c42f8c8e94273a8b2a39b8a0a1fde87fe68e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for bfjira-0.7.6.tar.gz:

Publisher: release.yml on nwhobart/bfjira

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bfjira-0.7.6-py3-none-any.whl.

File metadata

  • Download URL: bfjira-0.7.6-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bfjira-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 df6b26666852ae4f39997dc73a1c5ca7f7f50b1cc127f9a432cae0b93a0e151b
MD5 36ee82ceb4050994d127f2d6b047890d
BLAKE2b-256 b394b123e52993ed1092d0d6b04afe8d5dad5dac7e7e49663fffbc426c436f9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for bfjira-0.7.6-py3-none-any.whl:

Publisher: release.yml on nwhobart/bfjira

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page