Git Hooks to Check Commit Messages for Certain Text

Do you wish you could force people on your team to tie a commit message to a particular work item? Would you like there to be specific text in a commit message to help you tie it to an area of your application?

For some of you this may seem weird — it’s just code, after all. But in some industries and in some work cultures, being able to tell what you affected with each commit is important. It’s for you that the git pre-receive hook provides a solution.

I built this pre-receive hook in 2016, when I worked at a company that had a requirement that commits be tied to work items for “traceability” purposes. It seemed weird to me at the time, but since then I see its value. Developers work at the level of the code and of the commits, and seeing what work items (or “tickets”) a particular commit is tied to gives us a placeholder for that ‘why’ was this done.

Here is a link to that gist I created. In the future I’ll go into what git hooks are, and how you can create your own git hooks, for now, enjoy my rather terrible Python and this rather useful git hook.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s