pre-commit

censhare pre-commit hook is used to ensure the code’s correctness and style before any changes are committed to a repository. It checks every TypeScript and Sass file for TSLint and stylelint compliance and rejects the commit if any issues are found.

commit-msg

censhare commit-msg hook is used to ensure that the commit message follows the rules that are described below.

Mandatory: To get a good understanding on how to write a meaningful git commit message, we highly recommend you to have a look into this article: How to Write a Git Commit Message

The structure of the subject of a commit message should look like this:

  • C5-NNNNN [C5-NNNNN] [NNNNNNN] Add a cool feature

Where C5-NNNNN is the YouTrack ticket ID of the User Story/ Bug ticket, which is required. This ID can be followed by optional additional YouTrack IDs as well as any relevant Ecosphere ID(s), (optional). The subject should start with a capitalized verb in a declarative mood, e.g. use Add instead of Added.

The script checks for the following rules:

  1. The subject length should be a maximum of 70 characters
  2. Separate the subject from the body with a blank line
  3. Do not finish the subject line with a dot (.)
  4. The subject should start with a ticket number like 'C5-NNNNN ...'
  5. Subjects which start with the phrases displayed below, are ignored:
    • Merge ...
    • Revert ...
    • Increment of a server release build ID
  6. Double spaces are not allowed in the subject
  7. The first word in the subject should be capitalised
  8. Invisible symbols (like tabs) are not allowed
  9. Wrap the body lines at 72 characters

Installation

A manual hooks installation is no longer required. Git hooks are copied to the .git folder automatically, by simply executing one of the following commands:

censhare-Server/bin/build.sh copy.git-hooks

or

censhare-Server/bin/build.sh init

For Windows users, execute the same command by using the build.bat script instead.

The script does the following:

  1. It ensures that the .git folder exists, if not, it will not proceed to the steps below
  2. It copies the script files of the git hooks to the .git/hooks folder
  3. It makes the pre-commit script executable