Skip to main content

short_commit_str

Function short_commit_str 

Source
pub fn short_commit_str(commit: &str) -> String
Expand description

Truncate a full commit SHA string to SHORT_COMMIT_LEN characters. Returns the input unchanged when it’s already shorter or equal in length. Use this any time the SHA arrives as a string (e.g. deserialized from a manifest or read from a template var) rather than running git rev-parse --short again — saves a subprocess and keeps the length convention in one place.

Empty input returns empty; callers needing fail-closed semantics (e.g. publish-only’s commit cross-check) check is_empty() before calling.