use std::collections::{BTreeMap, HashMap};
use crate::git::Commit;
pub type ComponentMap = BTreeMap<String, Vec<Commit>>;
pub struct SectionMap {
pub sections: HashMap<String, ComponentMap>,
}
impl SectionMap {
pub fn from_commits(commits: Vec<Commit>) -> SectionMap {
let mut sm = SectionMap {
sections: HashMap::new(),
};
for entry in commits {
if !entry.breaks.is_empty() {
let comp_map = sm
.sections
.entry("Breaking Changes".to_owned())
.or_default();
let sec_map = comp_map.entry(entry.component.clone()).or_default();
sec_map.push(entry.clone());
}
let comp_map = sm.sections.entry(entry.commit_type.clone()).or_default();
let sec_map = comp_map.entry(entry.component.clone()).or_default();
sec_map.push(entry);
}
sm
}
}