field_ios

In-the-field app for Radroots on iOS
git clone https://radroots.dev/git/field_ios.git
Log | Files | Refs | README | LICENSE

provenance.rs (790B)


      1 pub(crate) fn is_full_revision(value: &str) -> bool {
      2     value.len() == 40
      3         && value
      4             .bytes()
      5             .all(|byte| byte.is_ascii_hexdigit() && !byte.is_ascii_uppercase())
      6 }
      7 
      8 #[cfg(test)]
      9 mod tests {
     10     use super::is_full_revision;
     11 
     12     #[test]
     13     fn only_full_lowercase_git_revisions_are_accepted() {
     14         assert!(is_full_revision("0123456789abcdef0123456789abcdef01234567"));
     15         assert!(!is_full_revision("0123456"));
     16         assert!(!is_full_revision(
     17             "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
     18         ));
     19         assert!(!is_full_revision(
     20             "0123456789ABCDEF0123456789abcdef01234567"
     21         ));
     22         assert!(!is_full_revision(
     23             "g123456789abcdef0123456789abcdef01234567"
     24         ));
     25     }
     26 }