Struct clog::SectionMap
[−]
[src]
pub struct SectionMap { pub sections: HashMap<String, ComponentMap>, }
A struct which holds sections to and components->commits map
Fields
sections: HashMap<String, ComponentMap>
Methods
impl SectionMap
[src]
fn from_commits(commits: Vec<Commit>) -> SectionMap
Creates a section map from a vector of commits, which we can then iterate through and write
Example
let clog = Clog::new().unwrap_or_else(|e| { println!("Error initializing: {}", e); std::process::exit(1); }); // Get the commits we're interested in and create the section map... let sm = SectionMap::from_commits(clog.get_commits()); // Open and prepend, or create the changelog file... let mut contents = String::new(); File::open(&Path::new(&clog.changelog[..])).map(|mut f| f.read_to_string(&mut contents).ok()).ok(); let mut file = File::create(&Path::new(&clog.changelog[..])).ok().unwrap(); // Write the header... let mut writer = LogWriter::new(&mut file, &clog); writer.write_header().ok().expect("failed to write header"); // Write the sections for (sec, secmap) in sm.sections { writer.write_section(&sec[..], &secmap.iter() .collect::<BTreeMap<_,_>>()) .ok() .expect(&format!("failed to write {}", sec)[..]); } writer.write(&contents[..]).ok().expect("failed to write contents");