#!/bin/sh
# Shared branch slug sanitization for CI jobs.
# Strips prefix (feature/, fix/, etc.), lowercases, replaces non-alphanum, truncates to 20 chars.
sanitize_branch() {
    echo "$1" | sed -E 's#^(feature|fix|feat|hotfix)/##' \
      | tr '[:upper:]' '[:lower:]' \
      | sed 's/[^a-z0-9-]/-/g' \
      | sed 's/--*/-/g; s/^-//; s/-$//' \
      | cut -c1-20 \
      | sed 's/-$//'
}
