Our Git hooks ensure the quality and conformance of the development process.
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:
- The subject length should be a maximum of 70 characters
- Separate the subject from the body with a blank line
- Do not finish the subject line with a dot (.)
- The subject should start with a ticket number like 'C5-NNNNN ...'
- Subjects which start with the phrases displayed below, are ignored:
- Merge ...
- Revert ...
- Increment of a server release build ID
- Double spaces are not allowed in the subject
- The first word in the subject should be capitalised
- Invisible symbols (like tabs) are not allowed
- 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:
- It ensures that the
.git
folder exists, if not, it will not proceed to the steps below - It copies the script files of the git hooks to the
.git/hooks
folder - It makes the pre-commit script executable