use std::collections::HashMap;
use std::collections::BTreeMap;
use 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_insert(BTreeMap::new());
let sec_map = comp_map.entry(entry.component.clone()).or_insert(vec![]);
sec_map.push(entry.clone());
}
let comp_map = sm.sections.entry(entry.commit_type.clone()).or_insert(BTreeMap::new());
let sec_map = comp_map.entry(entry.component.clone()).or_insert(vec![]);
sec_map.push(entry);
}
sm
}
}