Skip to content

prepare-commit-msg hook which adds a ticket number (think Jira and the like) prefix to your commits.

Notifications You must be signed in to change notification settings

Spirits-/ticket-adder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ticket Adder

A simple prepare-commit-msg git hook which checks the branch name you're in, attempts to extract a ticket number from it and prepends it to the commit message, unless the message already contains it. This is more of an experiment than anything else, so use at your own risk.

How to use

Since the regex pattern is hardcoded, you'll have to build it yourself. Install Rust, clone/download the repo, change the regex pattern to fit your needs (TICKET_PATTERN global constant), run cargo build --release, and throw the resulting binary file found in target/release into your projects .git/hooks folder. Enjoy never having to remember to add the ticket to a commit ever again.

This is my first time coding in Rust, so improvements are very welcome.

TODO

  • Methods can be broken up further to improve readability
  • Pass regex pattern from outside to avoid jumping through the build it yourself hoop
  • Specify types of commits that the script should run on

Acknowledgements

The majority of the code is coming from Justin Worthe, who was generous to write a tutorial on how to write git hooks in Rust, and already had code done to add the branch name to a commit message. My changes are fairly minimal.

https://code.worthe-it.co.za/rust-git-hooks.git/tree/src/bin/prepare-commit-msg.rs

https://www.worthe-it.co.za/blog/2017-08-29-writing-git-hooks-using-rust.html

About

prepare-commit-msg hook which adds a ticket number (think Jira and the like) prefix to your commits.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages