Coder Social home page Coder Social logo

cielquan / commit-msg-jira-hook Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 212 KB

Git hooks used with pre-commit to ensure proper jira issue linking in your commit messages.

License: GNU General Public License v3.0

Python 100.00%
pre-commit commit-msg jira preprare-commit-msg

commit-msg-jira-hook's Introduction

commit-msg-jira-hook

General Maintenance - not intended License Code Style - Black
Pipeline Azure DevOps builds Azure DevOps Coverage
Tools Poetry tox Pytest
VC VCS Website Versioning - semantic pre-commit
Github Github - Latest Release Github - Commits since latest release Github - Last Commit
Github - Stars Github - Forks Github - Contributors Github - Watchers

Git hooks used with pre-commit to ensure proper jira issue linking in your commit messages.

See also: https://github.com/pre-commit/pre-commit

Prerequisites

Works only with python version >= 3.6

A new version of pip that supports PEP-517/PEP-518 is required. When the setup fails try updating pip.

Usage

jira_commit_msg hook

This hook checks if the specified JIRA tag with issue number is present in the commit messages and can verify via the JRIA API if the issue number is valid.

Add this to your project's .pre-commit-config.yaml file:

repos:
- repo: https://github.com/Cielquan/commit-msg-jira-hook
  rev: '' # Use the ref you want to point at
  hooks:
  - id: jira_commit_msg
    args: ["--jira-tag=<TAG>", "--verify", "--jira-url=<URL>"]

Exchange the placeholders with your actual config. <URL> may be https://jira.atlassian.com.

Args to specify hook behavior:
  • --jira-tag is mandatory.
  • --verify can be omitted or changed to --no-verify to disable online verification.
  • --jira-url is mandatory if online verification is enabled or can be omitted otherwise.

Then add a .jira.ini file to your home directory, if you want to use online verification for the issue numbers, with the following config:

[jira]
JIRA_USERNAME = <YOUR EMAIL>
JIRA_TOKEN = <API TOKEN>

Get api token from here: https://id.atlassian.com/manage/api-tokens

Lastly install the hook:

$ pre-commit install -t commit-msg

jira_prepare_commit_msg hook

This hook extracts this specified JIRA tag and the issue number from your current git branch and add them to the beginning of your commit message.

Add this to your project's .pre-commit-config.yaml file:

repos:
- repo: https://github.com/Cielquan/commit-msg-jira-hook
  rev: '' # Use the ref you want to point at
  hooks:
  - id: jira_prepare_commit_msg
    args: ["--jira-tag=<TAG>"]

Exchange the placeholders with your actual config.

Args to specify hook behavior:
  • --jira-tag is mandatory.
  • --auto can be omitted or changed to --always to always prepend JIRA tag to commit msg even when its already there.
  • --deactivate-with takes a string which, when present at the start of the commit msg, deactivates adding the JIRA tag to commit msg and removes the string from the commit msg.
  • --no-error silences the error which occurs when the current branch has no JIRA tag.

Lastly install the hook:

$ pre-commit install -t prepare-commit-msg

Disclaimer

No active maintenance is intended for this project. You may leave an issue if you have a questions, bug report or feature request, but I cannot promise a quick response time.

commit-msg-jira-hook's People

Contributors

cielquan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

commit-msg-jira-hook's Issues

No Jira tag added when multi line commit msg

  • commit-msg-jira-hook version: 0.7.1
  • Python version: 3.8
  • Operating System: Winwos
  • I check open and closed issues.

Description

When having a multiline commit message, the jira_prepare_commit_msg hook does not add the jira tag in front. And the jira_commit_msg validates green too.

Update docs

Update docs with:

  • remove stages from example
  • add docs for new hook

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.