Skip to content

Instantly share code, notes, and snippets.

View Sergeon's full-sized avatar

Mauro Caffaratto Sergeon

  • http://www.geekorp.com
  • Madrid
View GitHub Profile
@Sergeon
Sergeon / commit-msg
Last active December 4, 2019 01:54
Commit-msg git hook with node.js
#!/usr/bin/env node
/**
*
* This code will ensure that before every commit in your client repository, your branch name and commit message adheres to a certain contract.
* In this example, branch names must be like 'feature/AP-22-some-feature-name' or 'hotfix/AP-30-invitation-email-not-sending', and commit messages must start like some issue code, like AP-100 or AP-101.
*
* 'AP' just stands for Acme Platform and is an example. I made this example with Jira in mind, since Jira issue codes have this structure -as far as I know-, but is pretty easy to change it to any other issue id like #100 or $-AP-120, or whatever.
*
* In order for this to work, you should go to .git/hooks in any git client repository and create a commit-msg file (or modify the provided by default, commit-msg.sample) with