12 releases

0.1.11 Mar 9, 2024
0.1.10 Oct 5, 2023
0.1.6 Sep 27, 2023

#251 in Parser implementations

Download history 494/week @ 2024-01-24 235/week @ 2024-01-31 547/week @ 2024-02-07 408/week @ 2024-02-14 379/week @ 2024-02-21 370/week @ 2024-02-28 1128/week @ 2024-03-06 375/week @ 2024-03-13 713/week @ 2024-03-20 679/week @ 2024-03-27 1449/week @ 2024-04-03 315/week @ 2024-04-10 730/week @ 2024-04-17 343/week @ 2024-04-24 648/week @ 2024-05-01 608/week @ 2024-05-08

2,373 downloads per month
Used in 6 crates (4 directly)

Apache-2.0

110KB
3K SLoC

Debian Changelog parser

This crate provides a parser for debian/changelog files, as described in the Debian policy, section 4.4.

The parser builds a CST. It is lossless - i.e. preserves formatting, and allows editing and partial parsing.

Example:


use std::io::Read;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file = std::fs::File::open("/usr/share/doc/rustc/changelog.Debian.gz")?;
    let mut gz = flate2::read::GzDecoder::new(file);
    let mut contents = String::new();
    gz.read_to_string(&mut contents)?;
    let changelog: debian_changelog::ChangeLog = contents.parse()?;
    for entry in changelog.entries() {
        println!(
            "{}: {}",
            entry.package().unwrap(),
            entry.version().unwrap().to_string()
        );
    }
    Ok(())
}

Or to update an existing changelog file:


use std::io::Read;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file = std::fs::File::open("debian/changelog")?;
    let mut contents = String::new();
    file.read_to_string(&mut contents)?;
    let changelog: debian_changelog::ChangeLog = contents.parse()?;
    changelog.auto_add_change(
        &["* Make a change"],
        (
            "Jelmer Vernooij".to_string(),
            "jelmer@debian.org".to_string(),
        ),
        None,
        None,
    );
    std::fs::write("debian/changelog", changelog.to_string())?;
    Ok(())
}

Dependencies

~4.5–6.5MB
~112K SLoC