From 95645f23a095b0f3b8746ea403ba4914af7a494c Mon Sep 17 00:00:00 2001 From: Vansh Chaurasiya Date: Tue, 14 Oct 2025 22:04:42 +0530 Subject: [PATCH 1/3] Add branch validation guidelines to contributing documentation --- .husky/pre-push | 29 ++++++++++++++++++++++++ community/contributing-guidelines.md | 34 ++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .husky/pre-push diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100644 index 00000000..ccf56ac5 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# . "$(dirname "$0")/_/husky.sh" + +# Validate git branch name +echo "Validating branch name..." +branch_name=$(git symbolic-ref --short HEAD) +branch_name_regex='^((fix|docs|style|refactor|test|chore|perf|task|shared)\/[0-9A-Za-z-]+|misc\/[0-9A-Za-z-]+)$' + +if [[ $branch_name =~ $branch_name_regex ]]; then + echo "✅ Branch name is valid." +else + echo -e "\033[0;31m❌ Branch name is invalid. Please follow the format: /-.\033[0m" + echo "Example:" + echo -e "\033[0;32m fix/1234-fix-bug or misc-1234-description\033[0m" + echo "" + echo -e "\033[0;34mValid types are:\033[0m" + echo -e "\033[0;34m fix/123 A bug fix\033[0m" + echo -e "\033[0;34m docs/123 Documentation only changes\033[0m" + echo -e "\033[0;34m style/123 Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)\033[0m" + echo -e "\033[0;34m refactor/123 A code change that neither fixes a bug nor adds a feature\033[0m" + echo -e "\033[0;34m test/123 Adding missing tests or correcting existing tests\033[0m" + echo -e "\033[0;34m chore/123 Changes to the build process or auxiliary tools and libraries such as documentation generation\033[0m" + echo -e "\033[0;34m perf/123 A code change that improves performance\033[0m" + echo -e "\033[0;34m story/123 A new feature or user story\033[0m" + echo -e "\033[0;34m task/123 A task that needs to be done\033[0m" + echo -e "\033[0;34m shared/123 Shared code or resources\033[0m" + echo -e "\033[0;34m misc/123 Miscellaneous changes\033[0m" + exit 1 +fi \ No newline at end of file diff --git a/community/contributing-guidelines.md b/community/contributing-guidelines.md index 41adde4d..f4d285ff 100644 --- a/community/contributing-guidelines.md +++ b/community/contributing-guidelines.md @@ -12,6 +12,10 @@ sidebar_position: 2 - [How to set up recode hive:](#how-to-set-up-recode-hive) - [Environment Setup (for GitHub API access)](#environment-setup-for-github-api-access) - [Contributing to recode hive](#contributing-to-recode-hive) +- [Branch Validation](#branch-validation) + - [Valid Branch Name Pattern](#valid-branch-name-pattern) + - [Example Branch Names](#example-branch-names) + - [Valid Types](#valid-types) - [Commit Message Format](#commit-message-format) - [Example Commit Messages:](#example-commit-messages) - [Using Commitizen with Husky](#using-commitizen-with-husky) @@ -130,6 +134,36 @@ We welcome contributions! Follow these steps to get started. git checkout -b feature-name ``` + ## Branch Validation + + To ensure that branch names follow our naming conventions, use the following guidelines. The branch name should match the required pattern, and feedback will be provided if it does not. + + ### Valid Branch Name Pattern + + Branch names should follow this regex pattern: + + ``` + ^((fix|docs|style|refactor|test|chore|perf|task|shared)\/-[0-9A-Za-z-]+|misc-[0-9A-Za-z-]+)$ + ``` + + ### Example Branch Names + + - `fix/1234-fix-bug` + - `misc-1234-description` + + ### Valid Types + + - **fix:** A bug fix + - **docs:** Documentation only changes + - **style:** Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) + - **refactor:** A code change that neither fixes a bug nor adds a feature + - **test:** Adding missing tests or correcting existing tests + - **chore:** Changes to the build process or auxiliary tools and libraries such as documentation generation + - **perf:** A code change that improves performance + - **task:** A task that needs to be done + - **shared:** Shared code or resources + - **misc:** Miscellaneous changes + 6. **Commit Your Changes** ```bash From 21a9d1cfa4e252d34ed02a323984843c9f699b6e Mon Sep 17 00:00:00 2001 From: Vansh Chaurasiya Date: Tue, 14 Oct 2025 22:06:24 +0530 Subject: [PATCH 2/3] Remove detailed branch type examples from pre-push validation script --- .husky/pre-push | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index ccf56ac5..bb8b9fd5 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -12,18 +12,5 @@ else echo -e "\033[0;31m❌ Branch name is invalid. Please follow the format: /-.\033[0m" echo "Example:" echo -e "\033[0;32m fix/1234-fix-bug or misc-1234-description\033[0m" - echo "" - echo -e "\033[0;34mValid types are:\033[0m" - echo -e "\033[0;34m fix/123 A bug fix\033[0m" - echo -e "\033[0;34m docs/123 Documentation only changes\033[0m" - echo -e "\033[0;34m style/123 Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)\033[0m" - echo -e "\033[0;34m refactor/123 A code change that neither fixes a bug nor adds a feature\033[0m" - echo -e "\033[0;34m test/123 Adding missing tests or correcting existing tests\033[0m" - echo -e "\033[0;34m chore/123 Changes to the build process or auxiliary tools and libraries such as documentation generation\033[0m" - echo -e "\033[0;34m perf/123 A code change that improves performance\033[0m" - echo -e "\033[0;34m story/123 A new feature or user story\033[0m" - echo -e "\033[0;34m task/123 A task that needs to be done\033[0m" - echo -e "\033[0;34m shared/123 Shared code or resources\033[0m" - echo -e "\033[0;34m misc/123 Miscellaneous changes\033[0m" exit 1 fi \ No newline at end of file From 31ac969ca07b8c35eb0f6474885e371666f4881b Mon Sep 17 00:00:00 2001 From: Vansh Chaurasiya Date: Tue, 14 Oct 2025 22:07:40 +0530 Subject: [PATCH 3/3] Add 'feat' type to branch name validation regex --- .husky/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/pre-push b/.husky/pre-push index bb8b9fd5..cc5465d3 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -4,7 +4,7 @@ # Validate git branch name echo "Validating branch name..." branch_name=$(git symbolic-ref --short HEAD) -branch_name_regex='^((fix|docs|style|refactor|test|chore|perf|task|shared)\/[0-9A-Za-z-]+|misc\/[0-9A-Za-z-]+)$' +branch_name_regex='^((fix|feat|docs|style|refactor|test|chore|perf|task|shared)\/[0-9A-Za-z-]+|misc\/[0-9A-Za-z-]+)$' if [[ $branch_name =~ $branch_name_regex ]]; then echo "✅ Branch name is valid."