Validate Feature Branch
Validate that the current Git branch follows the expected feature branch naming conventions.
Prerequisites
- Check if Git is available by running
git rev-parse --is-inside-work-tree 2>/dev/null - If Git is not available, output a warning and skip validation:
[specify] Warning: Git repository not detected; skipped branch validation
Validation Rules
Get the current branch name:
bash
git rev-parse --abbrev-ref HEADThe branch name's final path segment must start with one of these feature markers:
- Sequential:
[0-9]\{3,\}-(e.g.,001-feature-name,042-fix-bug,1000-big-feature,jdoe/web/008-guided-tour) - Timestamp:
[0-9]\{8\}-[0-9]\{6\}-(e.g.,20260319-143022-feature-name,jdoe/web/20260319-143022-feature-name)
Execution
If on a feature branch (matches either pattern):