Skip to content

Commit 76ea794

Browse files
committed
chore: enforce conventional branch naming and align renovate prefix
Signed-off-by: Jeremy Ho <jujaga@gmail.com>
1 parent 6b7ec63 commit 76ea794

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

branch.helper.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
import { existsSync, lstatSync, readFileSync } from 'node:fs';
44
import { dirname, join, isAbsolute, parse, resolve } from 'node:path';
55

6-
const validBranchRegex =
7-
/^(main|((bugfix|chore|ci|docs|feature|hotfix|perf|refactor|release|renovate|security|style|test)\/[a-z0-9]+([.-][a-z0-9]+)*))$/; // eslint-disable-line max-len
6+
/**
7+
* Conventional Branch Naming Convention
8+
* @see https://conventional-branch.github.io
9+
*/
10+
const conventionalBranchRegex = /^(main|((bugfix|chore|feature|hotfix|release)\/[a-z0-9]+([.-][a-z0-9]+)*))$/;
811

912
/**
1013
* Finds the actual git directory. Handles standard .git folders and worktree .git files.
@@ -64,12 +67,20 @@ function getCurrentBranch(): string {
6467
function main() {
6568
const branch = getCurrentBranch();
6669

67-
if (validBranchRegex.test(branch)) {
70+
if (conventionalBranchRegex.test(branch)) {
6871
process.stdout.write(`Branch name '${branch}' is valid.\n`);
6972
process.exit(0);
7073
} else {
71-
process.stderr.write(`Error: Invalid branch name '${branch}'.\n`);
72-
process.stderr.write(`Branches must match: ${validBranchRegex.source}\n`);
74+
process.stderr.write(`
75+
Error: Invalid branch name '${branch}'.
76+
77+
This project enforces Conventional Branches.
78+
See: https://conventional-branch.github.io
79+
Example: feature/login-page or bugfix/ticket-123
80+
81+
Rename your current branch with:
82+
git branch -m <type>/<description>
83+
`);
7384
process.exit(1);
7485
}
7586
}

renovate.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": ["github>bcgov/renovate-config#2025.10.1"],
44
"automerge": true,
5+
"branchPrefix": "chore",
56
"dependencyDashboard": true,
67
"draftPR": false,
78
"minimumReleaseAge": "3 days",

0 commit comments

Comments
 (0)