/// Writes a particular section of a changelog
Writes a particular section of a changelog
Writes a particular section of a changelog
fn write_section(&mut self,
                     options: &Clog,
                     section: &BTreeMap<&String, &Vec<Commit>>)
                     -> WriterResult {
        if section.len() == 0 {
            write!(self.0, "\"commits\":null").unwrap();
            return Ok(())
        }
        write!(self.0, "\"commits\":[").unwrap();
        let mut s_it = section.iter().peekable();
        while let Some((component, entries)) = s_it.next() {
            let mut e_it = entries.iter().peekable();
            debugln!("Writing component: {}", &*component);
            while let Some(entry) = e_it.next() {
                debugln!("Writing commit: {}", &*entry.subject);
                write!(self.0, "{{\"component\":").unwrap();
                if component.is_empty() {
                    write!(self.0, "null,").unwrap();
                } else {
                    write!(self.0, "{:?},", component).unwrap();
                }
                write!(
                    self.0 , "\"subject\":{:?},\"commit_link\":{:?},\"closes\":",
                    entry.subject,
                    options.link_style
                           .commit_link(&*entry.hash, &*options.repo)
                ).unwrap();
                if !entry.closes.is_empty() {
                    write!(self.0, "[").unwrap();
                    let mut c_it = entry.closes.iter().peekable();
                    while let Some(issue) = c_it.next() {
                        write!(self.0,
                            "{{\"issue\":{},\"issue_link\":{:?}}}",
                            issue,
                            options.link_style.issue_link(issue, &options.repo)
                        ).unwrap();
                        if c_it.peek().is_some() {
                            debugln!("There are more close commits, adding comma");
                            write!(self.0, ",").unwrap();
                        } else {
                            debugln!("There are no more close commits, no comma required");
                        }
                    }
                    write!(self.0,
                        "],").unwrap();
                }  else {
                    write!(self.0, "null,").unwrap();
                }
                write!(self.0 , "\"breaks\":").unwrap();
                if !entry.breaks.is_empty() {
                    write!(self.0, "[").unwrap();
                    let mut c_it = entry.closes.iter().peekable();
                    while let Some(issue) = c_it.next() {
                        write!(self.0,
                            "{{\"issue\":{},\"issue_link\":{:?}}}",
                            issue,
                            options.link_style.issue_link(issue, &options.repo)
                        ).unwrap();
                        if c_it.peek().is_some() {
                            debugln!("There are more breaks commits, adding comma");
                            write!(self.0, ",").unwrap();
                        } else {
                            debugln!("There are no more breaks commits, no comma required");
                        }
                    }
                    write!(self.0,
                        "]}}").unwrap();
                }  else {
                    write!(self.0, "null}}").unwrap();
                }
                if e_it.peek().is_some() {
                    debugln!("There are more commits, adding comma");
                    write!(self.0, ",").unwrap();
                } else {
                    debugln!("There are no more commits, no comma required");
                }
            }
            if s_it.peek().is_some() {
                debugln!("There are more sections, adding comma");
                write!(self.0, ",").unwrap();
            } else {
                debugln!("There are no more commits, no comma required");
            }
        }
        write!(self.0, "]").unwrap();
        Ok(())
    }
fn write_section ( & mut self , options : & Clog , section : & BTreeMap < & String , & Vec < Commit > > ) -> WriterResult { if section . len ( ) == 0 { write ! ( self 0 " \" \" " ) . unwrap ( ) ; return Ok ( ( ) ) } write ! ( self 0 " \" \" " ) . unwrap ( ) ; let mut s_it = section . iter ( ) . peekable ( ) ; while let Some ( ( component , entries ) ) = s_it . next ( ) { let mut e_it = entries . iter ( ) . peekable ( ) ; debugln ! ( " " component ) ; while let Some ( entry ) = e_it . next ( ) { debugln ! ( " " entry subject ) ; write ! ( self 0 " \" \" " ) . unwrap ( ) ; if component . is_empty ( ) { write ! ( self 0 " " ) . unwrap ( ) ; } else { write ! ( self 0 " " component ) . unwrap ( ) ; } write ! ( self 0 " \" \" \" \" \" \" " entry subject options link_style commit_link ( entry hash options repo ) ) . unwrap ( ) ; if ! entry . closes . is_empty ( ) { write ! ( self 0 " " ) . unwrap ( ) ; let mut c_it = entry . closes . iter ( ) . peekable ( ) ; while let Some ( issue ) = c_it . next ( ) { write ! ( self 0 " \" \" \" \" " issue options link_style issue_link ( issue options repo ) ) . unwrap ( ) ; if c_it . peek ( ) . is_some ( ) { debugln ! ( " " ) ; write ! ( self 0 " " ) . unwrap ( ) ; } else { debugln ! ( " " ) ; } } write ! ( self 0 " " ) . unwrap ( ) ; } else { write ! ( self 0 " " ) . unwrap ( ) ; } write ! ( self 0 " \" \" " ) . unwrap ( ) ; if ! entry . breaks . is_empty ( ) { write ! ( self 0 " " ) . unwrap ( ) ; let mut c_it = entry . closes . iter ( ) . peekable ( ) ; while let Some ( issue ) = c_it . next ( ) { write ! ( self 0 " \" \" \" \" " issue options link_style issue_link ( issue options repo ) ) . unwrap ( ) ; if c_it . peek ( ) . is_some ( ) { debugln ! ( " " ) ; write ! ( self 0 " " ) . unwrap ( ) ; } else { debugln ! ( " " ) ; } } write ! ( self 0 " " ) . unwrap ( ) ; } else { write ! ( self 0 " " ) . unwrap ( ) ; } if e_it . peek ( ) . is_some ( ) { debugln ! ( " " ) ; write ! ( self 0 " " ) . unwrap ( ) ; } else { debugln ! ( " " ) ; } } if s_it . peek ( ) . is_some ( ) { debugln ! ( " " ) ; write ! ( self 0 " " ) . unwrap ( ) ; } else { debugln ! ( " " ) ; } } write ! ( self 0 " " ) . unwrap ( ) ; Ok ( ( ) ) }
Writes a particular section of a changelog
Writes a particular section of a changelog
&mut self
options
&Clog
section
&BTreeMap<&String, &Vec<Commit>>