Expand description
Branch-slug normalization (spec §3).
A slug is a filesystem-safe rendering of a branch name, used only for
directory names; the real branch name is always preserved in Git. The rules:
(1) replace / and \ with -; (2) replace any run of characters outside
[a-zA-Z0-9.-] with -; (3) collapse consecutive - into one; (4) strip
leading/trailing -; (5) if the result is empty, fall back to the short
commit hash of the base ref (supplied by the caller via
slugify_with_fallback).
Functions§
- slugify
- Normalizes
branchinto a slug, applying rules 1–4. May return an empty string (e.g. for a branch consisting only of separators); useslugify_with_fallbackto apply rule 5. - slugify_
with_ fallback - Like
slugify, but applies rule 5: when the normalized slug is empty, returnfallback(the short commit hash of the base ref).