Git semantic messages

5

Eventually, as I browse through the thousands of GitHub repositories, I repair myself with certain standardized commit messages:

  

feat (*): initiate re-write

Or:

  

refactor (*): remove unwanted files

What are these words ( feat , refactor ...) that precede the message itself?
There are others, but I only mentioned two of them.

With a brief search, I have been able to conclude that they are semantic commit messages. But what are the rules for using them? And how to use them the right way?

    
asked by anonymous 09.09.2018 / 03:03

1 answer

2

The semantic commits in the way you described were proposed in an AngularJS conventions document . They have been documented and widely used by Karma , an open source tests for JavaScript. Today, many projects maintained by the community use it, adapting to its uses.

Guidelines recommend using such conventions in the commit message by:

  • Automatic changelog generation
  • Easy navigation in Git history
  • The proposed semantic commit message pattern is:

    <tipo>(<escopo>): <assunto>
    
    <corpo>
    
    <rodapé>
    

    Being <tipo> of the following values:

  • feat : when it comes to a new feature ( feature )
  • fix : when it comes to a bug fix
  • docs : when you make a change in the documentation
  • style : when it comes to code formatting
  • refactor : when it comes to code refactoring in production
  • test : When adding or refactoring tests, no impact on production code
  • chore : when you add or edit Grunt tasks , or Webpack, also without production impact
  • The <escopo> is optional, especially if the change is global, but good examples would be init , runner , watcher , config , web-server , proxy . >

    For the% of the commit message it is recommended:

  • Use the imperative form in the present tense of verbs. Prefer "change" to "changed" or "changes"
  • Include the reasons for changes in the code compared to the previous behavior
  • The <corpo> can be dedicated to important notes and warnings, as if there are radical changes in the code that fit a note. For example:

    MUDANÇA RADICAL:
    A opção 'port-runner' da linha de comando mudou para 'runner-port', para que permaneça consistente com a sintaxe do arquivo de configuração.
    Para migrar seu projeto, mude todos os comandos, onde você usa '--port-runner', para '--runner-port'.
    

    It can also be used for integrations, such as closing issues on GitHub using the commit message.

    Closes #123, #456, #789
    

    As an open source initiative, these guidelines are maintained by the community and reviewed in articles. One of the most influential is Sparkbox's Semantic Commit Messages .

      

    See how a minor change to your commit message style can make you a better programmer. I use the rigid commit message format, and it makes me a better programmer. You'll never again be tempted to include a bug fix and feature in the same commit. My <rodapé> is now an easy-to-skim changelog.

    A sample commit message following this pattern:

    fix($compilação): testes unitários no IE9
    
    Versões mais antigas do IE serializam HTML com tudo maiúsculo, mas o IE9 não.
    Seria melhor esperar um *case insensitive*, mas o Jasmine não aceita expressões regulares.
    
    Closes #392
    MUDANÇA RADICAL: quanto ao foo.bar, foo.baz deve ser utilizado ao invés disso.
    
        
    06.10.2018 / 04:58