type t = string let is_hex = function | '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' -> true | _ -> false let of_string value = let value = String.trim value in let length = String.length value in if length < 7 || length > 64 then Error "commit ID must contain 7 to 64 hexadecimal characters" else if not (String.for_all is_hex value) then Error "commit ID contains a non-hexadecimal character" else Ok (String.lowercase_ascii value) let to_string value = value let short value = String.sub value 0 (min 8 (String.length value))