File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
requirements/time_tracker_api Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ repos :
2+ - repo : local
3+ hooks :
4+ - id : semantic-commit-msg
5+ name : Check semantic commit message format
6+ entry : python ./commons/git_hooks/enforce_semantic_commit_msg.py
7+ language : python
8+ stages : [commit-msg]
Original file line number Diff line number Diff line change 1+ import re
2+ import sys
3+
4+ ERROR_MSG = """
5+ Commit failed!
6+ Please use semantic commit message format. Examples:
7+ 'feat: Applying some changes'
8+ 'fix: Fixing something broken'
9+ 'feat(config): Fix something in config files'
10+
11+ For more details in commit message format, review https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits
12+ """
13+
14+ SUCCESS_MSG = "Commit succeed!. Semantic commit message is correct."
15+
16+ COMMIT_MSG_REGEX = r'(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert)(\([\w\-]+\))?:\s.*'
17+
18+
19+ # Get the commit message file
20+ commit_msg_file = open (sys .argv [1 ]) # The first argument is the file
21+ commit_msg = commit_msg_file .read ()
22+
23+
24+ if re .match (COMMIT_MSG_REGEX , commit_msg ) is None :
25+ print (ERROR_MSG )
26+ sys .exit (1 )
27+
28+ print (SUCCESS_MSG )
29+ sys .exit (0 )
Original file line number Diff line number Diff line change @@ -13,3 +13,6 @@ pytest-mock==2.0.0
1313
1414# Coverage
1515coverage==4.5.1
16+
17+ # Git hooks
18+ pre-commit==2.2.0
You can’t perform that action at this time.
0 commit comments