pub fn ref_part(s: &str) -> String
s as one component of a git ref or a directory name: anything outside [A-Za-z0-9._-] becomes -, leading dots and dashes go, and a .lock suffix (which git forbids) is defused.
s
[A-Za-z0-9._-]
-
.lock