From 072784d6410ef1e178821a82b18797c65a1dc5f6 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Thu, 7 Mar 2024 22:28:29 +0000 Subject: [PATCH] Create pre-commit --- .githooks/pre-commit | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000..166b3fe --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,13 @@ +LC_ALL=C + +local_branch="$(git rev-parse --abbrev-ref HEAD)" + +valid_branch_regex="^(dependabot|feature|fix|docs|style|refactor|perf|hotfix|test|chore|create)(\/[a-zA-Z0-9._-]+)+$" + +message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again." + +if [[ ! $local_branch =~ $valid_branch_regex ]] +then + echo "$message" + exit 1 +fi