Skip to content

Commit

Permalink
move SHA1_HASH_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrssreal committed May 7, 2024
1 parent 7c760cd commit cb825ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ use hex;
use object::GitObjectStore;

pub const MIN_USER_HASH_LEN: usize = 4;
pub const SHA1_HASH_SIZE: usize = 20;

fn hash_from_str(id_str: &str) -> Option<[u8; 20]> {

let id_len = id_str.len();

if id_len < MIN_USER_HASH_LEN || id_len > 40 {
if id_len < MIN_USER_HASH_LEN || id_len > SHA1_HASH_SIZE * 2 {
eprintln!("Invalid hash length.");
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::iter::{Peekable, Iterator};
use std::collections::HashMap;
use std::option::Option;

pub const SHA1_HASH_SIZE: usize = 20;
use crate::SHA1_HASH_SIZE;

// "Each entry has a sha1 identifier, pathname and mode."
#[derive(Debug, PartialEq)]
Expand Down

0 comments on commit cb825ec

Please sign in to comment.