#!/bin/sh

# If creating a new branch, validate its name
if [[ "$1" == "-b" || "$1" == "--branch" ]]; then
  NEW_BRANCH_NAME="$2"

  # Regular expression for valid branch names
  if [[ ! "$NEW_BRANCH_NAME" =~ ^(feature|bugfix|hotfix|release|experiment|docs|refactor|perf|test|chore|ci|build|style|revert|deps|config)\/[a-z0-9\-]+$ && 
        ! "$NEW_BRANCH_NAME" =~ ^(develop|master|main|releases)$ ]]; then
    echo "❌ ERROR: Branch name '$NEW_BRANCH_NAME' does not follow the naming convention (e.g., feature/xyz, docs/api-docs, develop, master, main, releases)."
    exit 1
  fi
fi

exit 0
