Skip to main content

Module slug

Module slug 

Source
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 branch into a slug, applying rules 1–4. May return an empty string (e.g. for a branch consisting only of separators); use slugify_with_fallback to apply rule 5.
slugify_with_fallback
Like slugify, but applies rule 5: when the normalized slug is empty, return fallback (the short commit hash of the base ref).