From e306e033f88d44c7a16c0f4f3619c0a269f64eda Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Feb 10 2018 09:31:14 +0000 Subject: wrap long lines in changelog entry Before: - Disable test_gdb for all arches and test_buffer for ppc64le in anticipation of the F28 mass rebuild After: - Disable test_gdb for all arches and test_buffer for ppc64le in anticipation of the F28 mass rebuil Signed-off-by: Igor Gnatenko --- diff --git a/Cargo.lock b/Cargo.lock index c1198fa..85f424d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -157,6 +157,7 @@ dependencies = [ "structopt 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e0c02cb..71f76fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,4 @@ rayon = "0.9" structopt = "0.1" structopt-derive = "0.1" tempdir = "0.3" +textwrap = "0.9" diff --git a/src/main.rs b/src/main.rs index 1cc51ed..425dab5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ extern crate structopt; #[macro_use] extern crate structopt_derive; extern crate tempdir; +extern crate textwrap; use std::path::PathBuf; use std::process::{self, Command}; @@ -16,6 +17,7 @@ use git2::Repository; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use structopt::StructOpt; use tempdir::TempDir; +use textwrap::Wrapper; #[derive(StructOpt, Debug)] #[structopt(name = "git-rpm-changelog")] @@ -42,6 +44,10 @@ fn run(opt: &Opt) -> Result<(), Error> { .to_str() .unwrap() ); + let chlog_entry_wrapper = Wrapper::new(80) + .initial_indent("- ") + .subsequent_indent(" ") + .break_words(false); let changelog = walker .into_par_iter() .map(|oid| { @@ -87,7 +93,7 @@ fn run(opt: &Opt) -> Result<(), Error> { } else { eprintln!("{}", String::from_utf8_lossy(&output.stderr)); } - let chlog_entry = format!("- {}", commit.summary().unwrap()); + let chlog_entry = chlog_entry_wrapper.fill(commit.summary().unwrap()); Ok(format!("{}\n{}", chlog_header, chlog_entry)) })