fn write_section(&mut self,
                     options: &Clog,
                     title: &str,
                     section: &BTreeMap<&String, &Vec<Commit>>)
                     -> WriterResult {
        if section.len() == 0 {
            return Ok(())
        }

        if let Err(..) = self.0.write(&format!("\n#### {}\n\n", title)[..].as_bytes()) {
            return Err(Error::WriteErr);
        }

        for (component, entries) in section.iter() {
            let nested = (entries.len() > 1) && !component.is_empty();

            let prefix = if nested {
                if let Err(..) = write!(self.0 , "* **{}:**\n", component) {
                    return Err(Error::WriteErr);
                }
                "  *".to_owned()
            } else if !component.is_empty() {
                format!("* **{}:**", component)
            } else {
                format!("* ")
            };

            for entry in entries.iter() {
                if let Err(..) = write!(
                                    self.0 , "{} {} ([{}]({})",
                                    prefix,
                                    entry.subject,
                                    &entry.hash[0..8],
                                    options.link_style
                                           .commit_link(&*entry.hash, &options.repo[..])
                                ) {
                    return Err(Error::WriteErr);
                }

                if !entry.closes.is_empty() {
                    let closes_string = entry.closes.iter()
                                                    .map(|s| format!("[#{}]({})",
                                                        &*s,
                                                        options.link_style.issue_link(&*s, &options.repo)))
                                                    .collect::<Vec<String>>()
                                                    .join(", ");

                    if let Err(..) = write!(self.0 , ", closes {}", closes_string) {
                        return Err(Error::WriteErr);
                    }
                }
                if !entry.breaks.is_empty() {
                    let breaks_string = entry.breaks.iter()
                                                    .map(|s| format!("[#{}]({})",
                                                        &*s,
                                                        options.link_style.issue_link(&*s, &options.repo)))
                                                    .collect::<Vec<String>>()
                                                    .join(", ");

                    // 5 = "[#]()" i.e. a commit message that only said "BREAKING"
                    if breaks_string.len() != 5 {
                        if let Err(..) = write!(self.0 , ", breaks {}", breaks_string) {
                            return Err(Error::WriteErr);
                        }
                    }
                }

                if let Err(..) = write!(self.0 , ")\n") {
                    return Err(Error::WriteErr);
                }
            }
        }

        Ok(())
    }
/// 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,
                     title: &str,
                     section: &BTreeMap<&String, &Vec<Commit>>)
                     -> WriterResult {
        if section.len() == 0 {
            return Ok(())
        }
        if let Err(..) = self.0.write(&format!("\n#### {}\n\n", title)[..].as_bytes()) {
            return Err(Error::WriteErr);
        }
        for (component, entries) in section.iter() {
            let nested = (entries.len() > 1) && !component.is_empty();
            let prefix = if nested {
                if let Err(..) = write!(self.0 , "* **{}:**\n", component) {
                    return Err(Error::WriteErr);
                }
                "  *".to_owned()
            } else if !component.is_empty() {
                format!("* **{}:**", component)
            } else {
                format!("* ")
            };
            for entry in entries.iter() {
                if let Err(..) = write!(
                                    self.0 , "{} {} ([{}]({})",
                                    prefix,
                                    entry.subject,
                                    &entry.hash[0..8],
                                    options.link_style
                                           .commit_link(&*entry.hash, &options.repo[..])
                                ) {
                    return Err(Error::WriteErr);
                }
                if !entry.closes.is_empty() {
                    let closes_string = entry.closes.iter()
                                                    .map(|s| format!("[#{}]({})",
                                                        &*s,
                                                        options.link_style.issue_link(&*s, &options.repo)))
                                                    .collect::<Vec<String>>()
                                                    .join(", ");
                    if let Err(..) = write!(self.0 , ", closes {}", closes_string) {
                        return Err(Error::WriteErr);
                    }
                }
                if !entry.breaks.is_empty() {
                    let breaks_string = entry.breaks.iter()
                                                    .map(|s| format!("[#{}]({})",
                                                        &*s,
                                                        options.link_style.issue_link(&*s, &options.repo)))
                                                    .collect::<Vec<String>>()
                                                    .join(", ");
                    // 5 = "[#]()" i.e. a commit message that only said "BREAKING"
                    if breaks_string.len() != 5 {
                        if let Err(..) = write!(self.0 , ", breaks {}", breaks_string) {
                            return Err(Error::WriteErr);
                        }
                    }
                }
                if let Err(..) = write!(self.0 , ")\n") {
                    return Err(Error::WriteErr);
                }
            }
        }
        Ok(())
    }
fn write_section ( & mut self , options : & Clog , title : & str , section : & BTreeMap < & String , & Vec < Commit > > ) -> WriterResult { if section . len ( ) == 0 { return Ok ( ( ) ) } if let Err ( .. ) = self . 0 . write ( & format ! ( " \n \n \n " title ) [ .. ] . as_bytes ( ) ) { return Err ( Error :: WriteErr ) ; } for ( component , entries ) in section . iter ( ) { let nested = ( entries . len ( ) > 1 ) && ! component . is_empty ( ) ; let prefix = if nested { if let Err ( .. ) = write ! ( self 0 " \n " component ) { return Err ( Error :: WriteErr ) ; } " " . to_owned ( ) } else if ! component . is_empty ( ) { format ! ( " " component ) } else { format ! ( " " ) } ; for entry in entries . iter ( ) { if let Err ( .. ) = write ! ( self 0 " " prefix entry subject entry hash [ 0 8 ] options link_style commit_link ( entry hash options repo [ ] ) ) { return Err ( Error :: WriteErr ) ; } if ! entry . closes . is_empty ( ) { let closes_string = entry . closes . iter ( ) . map ( | s | format ! ( " " s options link_style issue_link ( s options repo ) ) ) . collect :: < Vec < String > > ( ) . join ( " " ) ; if let Err ( .. ) = write ! ( self 0 " " closes_string ) { return Err ( Error :: WriteErr ) ; } } if ! entry . breaks . is_empty ( ) { let breaks_string = entry . breaks . iter ( ) . map ( | s | format ! ( " " s options link_style issue_link ( s options repo ) ) ) . collect :: < Vec < String > > ( ) . join ( " " ) ; // 5 = "[#]()" i.e. a commit message that only said "BREAKING" if breaks_string . len ( ) != 5 { if let Err ( .. ) = write ! ( self 0 " " breaks_string ) { return Err ( Error :: WriteErr ) ; } } } if let Err ( .. ) = write ! ( self 0 " \n " ) { return Err ( Error :: WriteErr ) ; } } } Ok ( ( ) ) }
Writes a particular section of a changelog
Writes a particular section of a changelog
&mut self
options
&Clog
title
&str
section
&BTreeMap<&String, &Vec<Commit>>
&mut self
options
&Clog
title
&str
section
&BTreeMap<&String, &Vec<Commit>>