DEV Community

Abner Soares Alves Junior
Abner Soares Alves Junior

Posted on


Faster Conventional Commits Messages

Conventional Commits is a specification to help creating an organized commit history.

This is not a tutorial explaining what it is, but a simple tip for automate some pieces when you are working with it.

The slow way πŸšΆβ€β™€οΈ

In your daily workflow, the team commits use to follow a pattern using the prefixes, like: feat:, chore(API):, fix:. It's become repetitive and can be optimized.

The faster way πŸƒβ€β™€οΈ

Here is a simple solution for my case, but this can be extended in many ways to your workflow.

function gitCommit() {
  git add .
  git commit -m "$1: $2"

alias gchore="gitCommit chore"
alias gfeat="gitCommit feat"
alias gfix="gitCommit fix"
alias gwip="gitCommit wip"
Enter fullscreen mode Exit fullscreen mode

The function takes 2 args, one is the prefix you want to be added, second is the message.

In my case, what I most use are these prefixes, so I've created an alias for every single one.

Now when I want to add all and commit I just run

$ g<prefix> "message to be commited"
Enter fullscreen mode Exit fullscreen mode

Going Further

Another good improvement is using oh-my-zsh combo with Git Plugin.
It brings a lot of aliases for other languages, other CLIs, like Heroku, Ruby, etc.

Using the Git Plugin the above function could be converted to:

function gitCommit() {
  gcmsg "$1: $2"
Enter fullscreen mode Exit fullscreen mode

Use your imagine and you can include other things as you need.

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.