File tree 2 files changed +28
-4
lines changed
2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,13 @@ Security - in case of vulnerabilities.
15
15
-->
16
16
17
17
## [ Unreleased]
18
-
19
- _ TBD _
18
+ ### Added
19
+ - Added hooks ` disallow-commits `
20
20
21
21
## [ 1.1.0] 2019-03-01
22
-
23
22
### Added
24
23
- Added hooks ` motivation `
25
24
- Added hooks ` files-watcher `
26
25
27
26
## [ 1.0.0] 2019-03-01
28
-
29
27
Initial release.
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ # The `pre-commit` hook to disallow commits to some branches.
3
+ # Useful for example to disallow commits directly to master branch.
4
+ # Example of config:
5
+ # ~~~
6
+ # [disallow-commits]
7
+ # branch = master
8
+ # branch = development
9
+ # ~~~
10
+
11
+ FCR=' \033[1;31m' # Red
12
+ NC=' \033[0m'
13
+
14
+ branch_name=" $( git rev-parse --abbrev-ref HEAD) "
15
+ closed_branches=$( git config --get-all disallow-commits.branch)
16
+
17
+ if [[ -z ${closed_branches} ]]; then
18
+ closed_branches=" master"
19
+ fi
20
+
21
+ for closed_branch in ${closed_branches} ; do
22
+ if [[ " ${branch_name} " =~ " ${closed_branch} " ]]; then
23
+ echo " ${FCR} You can't commit directly to ${closed_branch} branch${NC} "
24
+ exit 1
25
+ fi
26
+ done
You can’t perform that action at this time.
0 commit comments