Skip to content

Commit f46f751

Browse files
authored
Merge pull request #187 from opencrvs/add-husky
feat: Add husky branch validation
2 parents 2d8cce5 + bb790b7 commit f46f751

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

.husky/pre-push

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
branch=$(git rev-parse --abbrev-ref HEAD)
4+
pattern='^[a-z][a-z0-9\/\-]{1,29}$'
5+
6+
if [[ ! "$branch" =~ $pattern ]]; then
7+
echo """
8+
❌ Invalid branch name: '$branch'
9+
➡️ Branch names must match regex: $pattern
10+
- Start with a lowercase letter
11+
- Can contain lowercase letters, numbers, and hyphens
12+
- Length between 2 and 30 characters
13+
- Slashes '/' are allowed for hierarchical branch names
14+
Example: ocrvs-12345, feature-login, fix-bug123, refactor-api
15+
"""
16+
exit 1
17+
fi
18+
19+
exit 0

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"node": "22.x.x"
1111
},
1212
"license": "MPL-2.0",
13-
"husky": {
14-
},
13+
"husky": {},
1514
"scripts": {
1615
"environment:init": "ts-node infrastructure/environments/setup-environment.ts",
17-
"environment:upgrade": "yarn environment:init"
16+
"environment:upgrade": "yarn environment:init",
17+
"prepare": "husky"
1818
},
1919
"devDependencies": {
2020
"@octokit/core": "4.2.1",

0 commit comments

Comments
 (0)