DEV Community

Cover image for Git Graft: A NPX Tool & Git Hook in TypeScript & Node
Jacob Evans
Jacob Evans

Posted on

Git Graft: A NPX Tool & Git Hook in TypeScript & Node

Introduction

I decided I was tired of a GitFlow process. Every time I had to write a commit I had to prepend the JIRA ticket to the commit message, "It's in the branch, why can't it just take it from the branch!?" I kept asking myself. Finally, I said, I will just make that happen.

The Idea

Enter in the concept of Git Hooks, more famously known through tooling like Husky (awesome tool btw), however, there is a Git Hook for just about any part of the process of Git, and they have examples (written in shell, I'll get more into that later) in the .git/hooks directory. Ok so it's right there, I made a hook what is the big deal? I thought to myself "It took me forever to do this because of the overhead what if I removed that for others?" So I did.

The Tool

NPM

Technologies:

So it might come as a bit of a surprise but there are only 2 shell files in this whole CLI tool. They really just execute the JavaScript. Even crazier, I made the commit-msg hook entirely JavaScript little trick that I will get into later.

I will go over the CLI & Git Commit Message Hook in the following 2 more blog articles in the series. I want to keep this one short and more of a summary.

Top comments (0)