use std::hash::{DefaultHasher, Hash, Hasher};
use crate::remote::models::repo_config::RepositoryConfiguration;
pub struct CacheKeyGenerator;
impl CacheKeyGenerator {
pub fn generate_key(config: &RepositoryConfiguration) -> String {
let mut hasher = DefaultHasher::new();
config.url.hash(&mut hasher);
config.branch.hash(&mut hasher);
if let Some(ref commit) = config.commit_hash {
commit.hash(&mut hasher);
}
let hash = hasher.finish();
format!("{hash:x}")
}
pub fn generate_url_branch_key(url: &str, branch: &str) -> String {
let mut hasher = DefaultHasher::new();
url.hash(&mut hasher);
branch.hash(&mut hasher);
let hash = hasher.finish();
format!("{hash:x}")
}
}