All Projects → janniks → prepare-commit-msg

janniks / prepare-commit-msg

Licence: GPL-3.0 license
Automatically prefix commit messages with the current branch issue number

Programming Languages

shell
77523 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to prepare-commit-msg

Github Issue Templates
🔣 A collection of GitHub issue and pull request templates
Stars: ✭ 3,074 (+10878.57%)
Mutual labels:  issues, issue-tracker, issue
laravel-jira-rest-client
A Laravel interface for your Atlassians Jira application
Stars: ✭ 37 (+32.14%)
Mutual labels:  jira, atlassian, atlassian-jira
tiket
TIKET is a ticketing/helpdesk system to support and help you deal with issues/incidents in your organization or from customers.
Stars: ✭ 59 (+110.71%)
Mutual labels:  issue-tracker, issue-management, issue-tracking-system
treenga
Simple and fast issue tracking system
Stars: ✭ 36 (+28.57%)
Mutual labels:  issue-tracker, issue-management, issue-tracking-system
quickstart-atlassian-jira
Jira Software Data Center and Jira Service Desk Data Center with high availability and performance
Stars: ✭ 61 (+117.86%)
Mutual labels:  jira, atlassian
vira
Create and update your Jira issues while inside Vim!
Stars: ✭ 76 (+171.43%)
Mutual labels:  jira, atlassian
alfred-jira-search
Alfred Workflow to quickly search through Jira issues 🔎
Stars: ✭ 23 (-17.86%)
Mutual labels:  jira, issue
awesome-jira
📋 A curated list of awesome Atlassian's JIRA tips and tricks, tutorials and best practices.
Stars: ✭ 20 (-28.57%)
Mutual labels:  jira, atlassian-jira
linear-discord-serverless
Get linear's events forwarded to Discord webhooks through Vercel serverless functions.
Stars: ✭ 47 (+67.86%)
Mutual labels:  issue-tracker, issue
jira.js
A JavaScript/TypeScript wrapper for the JIRA Cloud, Service Desk and Agile REST API
Stars: ✭ 156 (+457.14%)
Mutual labels:  jira, atlassian
data-center-helm-charts
Helm charts for Atlassian's Data Center products
Stars: ✭ 77 (+175%)
Mutual labels:  jira, atlassian
Confluence-and-Jira
Docker部署并破解Jira、Confluence及相关插件;若图片加载不出来可以访问我的博客原文查看
Stars: ✭ 60 (+114.29%)
Mutual labels:  jira, atlassian
jira scan
A simple remote scanner for Atlassian Jira
Stars: ✭ 89 (+217.86%)
Mutual labels:  jira, atlassian-jira
atlassian-connect-core
[Laravel 5.5+] The easiest way to create an add-on for the JIRA and Confluence
Stars: ✭ 42 (+50%)
Mutual labels:  jira, atlassian
Actionview
An issue tracking tool based on laravel+reactjs for small and medium-sized enterprises, open-source and free, similar to Jira.
Stars: ✭ 1,357 (+4746.43%)
Mutual labels:  jira, issue-tracker
JirAgileR
User-friendly 🔹JIRA API wrapper. Track projects & issues from within R
Stars: ✭ 22 (-21.43%)
Mutual labels:  jira, atlassian
tickets
Basic ticket tracker build on Laravel PHP framework
Stars: ✭ 18 (-35.71%)
Mutual labels:  issues, jira
iguana
Iguana is an open source issue management system with a kanban board.
Stars: ✭ 39 (+39.29%)
Mutual labels:  issue-tracker, issue-management
jira-cli
🔥 [WIP] Feature-rich interactive Jira command line.
Stars: ✭ 809 (+2789.29%)
Mutual labels:  jira, atlassian
label-actions
🤖 GitHub Action that performs certain tasks when issues, pull requests or discussions are labeled or unlabeled
Stars: ✭ 60 (+114.29%)
Mutual labels:  issues, issue

Prefix Issue Number - Git Hook

This is a git hook for lazy people. 😴

Description 📚

This git hook automatically prepends a parsed issue number (from the current branch) to your commit messages on every commit. (See Usage for examples and details)

Example usage

This git hook requires ruby to be installed (already pre-installed by default on macOS).

Install 🚀

Install Script

To install simply run the following command. This requires curl to be installed.

sh <(curl -s https://raw.githubusercontent.com/janniks/prepare-commit-msg/master/scripts/install.sh)

If you choose the option to install globally, you will have to reinitialize all your git repositories. The following helpful command reinitializes all repositories found in sub-directories of the current directory.

find . -name .git -type d -prune -exec sh -c 'git --git-dir "{}" init' \;

Install Manually

If you prefer to install manually you can walk through the following steps:

  1. Copy the scripts/prepare-commit-msg script into your local git repository inside .git/hooks
  2. Edit the placeholders at the beginning of the script
  3. Make sure the is script executable by running chmod +x prepare-commit-msg
  4. Enjoy! Test it by committing anything!

Usage 🔧

Simply commit as you always would! This git hook also works with tools like Tower that use native git bindings.

This git hooks will look at the current branch (e.g. type/ABC-123-branch-name) and parse the issue number and project key (e.g. ABC 123) to use for prefixing commit messages. This can be useful in connection with tools like Jira.

  • If no issue number is found in the branch name, the commit message will not be modified.
  • If the commit message already contains an issue number, the commit message will not be modified.

Examples

Branch name Entered commit message Updated commit message
bugfix/ABC-012-add-initial-repo Set up repo [ABC-012] Set up repo
improvement/ABC-123-great-things Add files [ABC-123] Add files
feature/ABC-123-something-normal [XYZ-321] Something different not modified

Default Regular Expressions

These are the default regular expressions that are used by the script on install. They can easily be changed during install using the provided script or manually tweaked.

Parsing issue numbers from current branch name

/[.]*\/([\-\w]*?\-\d+)/

Detects issue number Does not detect issue number
feature/ABC-123-test-message abc-123-do-it
Improvement/XYZ-ABC-321-Crazy-Name simple-branch-name

Checking commit messages for existing issue numbers

/^\s*\[[\-\w]*\d\]/

Detects issue number Does not detect issue number
[ABC-123] Test message Test message
[XYZ-312] Message test [ABC] Testing stuff
[XYZ-ABCD-321] Awesome sauce [Add ABC-123 files]

Detecting automated commits by git

/(Merge\sbranch\s\'|\#\sRebase\s|This\sreverts\scommit\s)/

Ignores following commits
Merge branch 'testing' into master
# Rebase commit 9f3bc7b
This reverts commit 28da9f6

You can use tools like Regex101 to tweak and test these regular expressions.

FAQ & Problems

I already have a global git-template! Install manually and add the git hook file to your hooks directory in your existing git-template.

Uninstall 😖

If you're unhappy with this git hook:

  • Simply run rm -rf .git/hooks/prepare-commit-msg to uninstall locally
  • Or run rm -rf ~/.git-template/hooks/prepare-commit-msg to uninstall globally

Please let me know what you didn't like!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].