Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>BranchCommit ValidatorNew to Visual Studio Code? Get it now.
BranchCommit Validator

BranchCommit Validator

Utkarsh Lanjewar

|
12 installs
| (0) | Free
Enforce branch naming and commit message conventions to maintain consistent Git workflow standards
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Validate Branch - VS Code Extension

A powerful VS Code extension that enforces branch naming and commit message conventions to maintain consistent Git workflow standards across your projects.

Features

  • ✅ Branch Name Validation: Enforce consistent branch naming conventions
  • ✅ Commit Message Validation: Ensure commit messages follow established patterns
  • ✅ JIRA Integration: Built-in support for JIRA ticket-based workflows
  • ✅ Git Hooks Integration: Automatically install git hooks for repository-level enforcement
  • ✅ Real-time Feedback: Get immediate feedback with helpful examples when validation fails
  • ✅ Configurable Settings: Customize patterns and enable/disable features as needed

Supported Conventions

Branch Naming Conventions

JIRA Convention (Default)

Regex Pattern: ^(feature|bugfix|hotfix|release|chore)\/[A-Z]+-[0-9]+-[a-z0-9-]+$

Valid Examples:

  • feature/APC-2876-user-auth
  • bugfix/APC-1234-login-fix
  • hotfix/APC-5678-security-patch
  • release/APC-9999-v2-release
  • chore/APC-1111-update-deps

Pattern Breakdown:

  • Type: feature, bugfix, hotfix, release, or chore
  • Separator: / (forward slash)
  • Project Code: Uppercase letters followed by - (e.g., APC-, PROJ-)
  • Ticket Number: One or more digits (e.g., 2876, 1234)
  • Separator: - (hyphen)
  • Description: Lowercase letters, numbers, and hyphens only

Invalid Examples:

  • feature/user-auth ❌ (missing JIRA ticket)
  • Feature/APC-123-test ❌ (uppercase type)
  • feature/apc-123-test ❌ (lowercase project code)
  • feature/APC-123-Test ❌ (uppercase in description)
  • feature/APC-123_test ❌ (underscore not allowed)

Commit Message Conventions

JIRA Convention (Default)

Regex Pattern: ^\[[A-Z]+-[0-9]+\] (feat|fix|docs|style|refactor|test|chore)\([a-z0-9-]+\): .{1,80}$

Valid Examples:

  • [APC-2356] feat(auth): Add Login Functionality
  • [APC-1234] fix(ui): Resolve button alignment issue
  • [APC-5678] docs(readme): Update installation guide
  • [APC-9999] refactor(api): Simplify user service
  • [PROJ-4567] test(auth): Add unit tests for login
  • [DEV-8901] chore(deps): Update package dependencies

Pattern Breakdown:

  • Ticket Reference: [PROJECT-NUMBER] (e.g., [APC-2356])
  • Type: feat, fix, docs, style, refactor, test, or chore
  • Scope: Lowercase letters, numbers, and hyphens in parentheses (e.g., (auth), (ui))
  • Separator: : (colon and space)
  • Description: 1-80 characters describing the change

Invalid Examples:

  • feat: add login ❌ (missing JIRA ticket)
  • [APC-123] Feat(auth): Add login ❌ (uppercase type)
  • [apc-123] feat(auth): Add login ❌ (lowercase project code)
  • [APC-123] feat(Auth): Add login ❌ (uppercase scope)
  • [APC-123] feat(auth) Add login ❌ (missing colon)
  • [APC-123] feat(auth): ❌ (empty description)

Custom Patterns

You can define your own regex patterns for both branch names and commit messages using the custom pattern settings.

Commands

Access these commands via the Command Palette (Ctrl+Shift+P / Cmd+Shift+P):

  • Validate Branch: Validate Current Branch - Check if the current branch follows naming conventions
  • Validate Branch: Create New Branch (with validation) - Create a new branch with validation
  • Validate Branch: Create Commit (with validation) - Create a commit with message validation
  • Validate Branch: Install Git Hooks - Install git hooks for automatic validation
  • Validate Branch: Remove Git Hooks - Remove previously installed git hooks
  • Validate Branch: Open Settings - Open extension settings

Installation

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
  3. Search for "Validate Branch"
  4. Click Install

Configuration

Configure the extension through VS Code settings (File > Preferences > Settings or Ctrl+,):

Settings

  • validateBranch.branchPattern: Choose branch naming convention

    • Options: jira, custom
    • Default: jira
  • validateBranch.commitPattern: Choose commit message convention

    • Options: jira, custom
    • Default: jira
  • validateBranch.enableBranchValidation: Enable/disable branch validation

    • Default: true
  • validateBranch.enableCommitValidation: Enable/disable commit validation

    • Default: true
  • validateBranch.customBranchPattern: Custom regex for branch names

    • Used when branchPattern is set to custom
  • validateBranch.customCommitPattern: Custom regex for commit messages

    • Used when commitPattern is set to custom

Example Settings Configuration

{
  "validateBranch.branchPattern": "jira",
  "validateBranch.commitPattern": "jira",
  "validateBranch.enableBranchValidation": true,
  "validateBranch.enableCommitValidation": true,
  "validateBranch.customBranchPattern": "^(feature|bugfix|hotfix)\\/[A-Z]+-[0-9]+-[a-z0-9-]+$",
  "validateBranch.customCommitPattern": "^\\[[A-Z]+-[0-9]+\\] (feat|fix|docs): .{1,50}$"
}

Git Hooks Integration

The extension can install git hooks to enforce validation at the repository level:

  1. Run the command Validate Branch: Install Git Hooks
  2. The extension will create pre-commit, commit-msg, and post-checkout hooks in your .git/hooks directory
  3. These hooks will automatically validate commits and branches even when using git directly from the command line

Hook Behavior:

  • pre-commit: Validates branch name before allowing commits
  • commit-msg: Validates commit message format
  • post-checkout: Warns about invalid branch names after checkout

Usage Examples

Creating a New Branch

  1. Open Command Palette (Ctrl+Shift+P)
  2. Type "Validate Branch: Create New Branch"
  3. Enter branch name (e.g., feature/APC-2876-user-authentication)
  4. If valid, the branch will be created and checked out
  5. If invalid, you'll see an error with examples of valid names

Validating Current Branch

  1. Open Command Palette (Ctrl+Shift+P)
  2. Type "Validate Branch: Validate Current Branch"
  3. See if your current branch follows the configured convention

Creating a Commit

  1. Stage your changes (git add .)
  2. Open Command Palette (Ctrl+Shift+P)
  3. Type "Validate Branch: Create Commit"
  4. Enter commit message (e.g., [APC-2356] feat(auth): Add user login functionality)
  5. If valid, the commit will be created
  6. If invalid, you'll see an error with examples of valid messages

Error Messages

When validation fails, you'll see helpful error messages with examples:

Branch Validation Error

❌ Branch name "my-feature" doesn't follow the jira convention.

Examples:
feature/APC-2876-user-auth
bugfix/APC-1234-login-fix
hotfix/APC-5678-security-patch
release/APC-9999-v2-release
chore/APC-1111-update-deps

Commit Validation Error

❌ Commit message doesn't follow the jira convention.

Examples:
[APC-2356] feat(auth): Add Login Functionality
[APC-1234] fix(ui): Resolve button alignment issue
[APC-5678] docs(readme): Update installation guide
[APC-9999] refactor(api): Simplify user service

Terminal Integration

When git hooks are installed, terminal commands are also validated:

Branch Creation in Terminal

# This will fail validation
git checkout -b my-feature
# Output: ❌ Branch name 'my-feature' doesn't follow the jira convention.

# This will pass validation
git checkout -b feature/APC-2876-user-auth
# Output: ✅ Branch name follows jira convention

Commit in Terminal

# This will fail validation
git commit -m "fix login bug"
# Output: ❌ Commit message doesn't follow the jira convention.

# This will pass validation
git commit -m "[APC-1234] fix(auth): Resolve login validation issue"
# Output: ✅ Commit message validation passed

Custom Patterns

You can define custom regex patterns for both branch names and commit messages:

Custom Branch Pattern Examples

Simple Feature Branches:

^(feature|bugfix|hotfix)\/[a-z0-9-]+$

Matches: feature/user-login, bugfix/button-fix

Conventional with Ticket Numbers:

^(feat|fix|docs|style|refactor|test|chore)\/[A-Z]+-\d+-.+$

Matches: feat/PROJ-123-user-auth, fix/BUG-456-login-issue

Custom Commit Pattern Examples

Simple Conventional Commits:

^(feat|fix|docs|style|refactor|test|chore): .{1,50}$

Matches: feat: add user authentication, fix: resolve login issue

Angular Style with Scope:

^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,72}$

Matches: feat(auth): add login, fix: resolve issue

Troubleshooting

Extension Not Working

  • Ensure you're in a Git repository
  • Check that the workspace folder is properly opened
  • Verify extension settings are configured correctly
  • Check VS Code Developer Console for error messages

Git Hooks Not Working

  • Make sure you have write permissions to the .git/hooks directory
  • Verify that the hooks are executable (chmod +x .git/hooks/pre-commit)
  • Check that your shell supports the hook scripts
  • Ensure git hooks are not disabled globally (git config core.hooksPath)

Custom Patterns Not Working

  • Validate your regex pattern using an online regex tester
  • Ensure special characters are properly escaped (use \\ for \)
  • Test patterns with various input examples
  • Check the VS Code developer console for error messages

Common Issues

  • Hook permission denied: Run chmod +x .git/hooks/* in your repository
  • Pattern not matching: Test your regex with online tools like regex101.com
  • Extension not activating: Ensure you're in a workspace with a git repository

Contributing

  1. Fork the repository
  2. Create a feature branch (feature/APC-123-new-feature)
  3. Make your changes
  4. Test thoroughly with various scenarios
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Changelog

0.0.3

  • Initial release with JIRA convention support
  • Branch name validation with comprehensive regex patterns
  • Commit message validation with JIRA ticket integration
  • Git hooks integration for terminal command validation
  • Configurable settings with custom pattern support
  • Real-time feedback with helpful examples
  • Command palette integration for guided workflows
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft