chlog: number entries as backport, NMU or no-change rebuild
The version flags were never reachable: --backport was declared but not read, and compute_new_version's NMU/rebuild numbering sat behind a TODO asking for CLI wiring (the old positional-bool signature always received false). generate_entry now takes an EntryKind selected by three mutually exclusive flags, and is async because the backport numbering derives the Debian release number of the target series from distro-info: - --backport: 1.0-1 becomes 1.0-1~bpo12+1 (12 = release number of the target series, backport suite names accepted too). Re-running on an already-numbered version bumps the counter; series without a numeric Debian release (sid, Ubuntu series, UNRELEASED) are rejected before anything is written. - --nmu: 1.0-1 becomes 1.0-1.1 (native 1.0 becomes 1.0+nmu1). - --rebuild: 1.0-1 becomes 1.0-1build1. An explicit --version overrides all three. compute_new_version went from four positional bools to a private Bump enum; backport numbering reuses increment_suffix with a '~bpoNN+' suffix. The CLI prints the computed new version before opening the editor.
This commit is contained in:
+27
-6
@@ -7,8 +7,6 @@ use pkh::context::ContextConfig;
|
||||
|
||||
extern crate flate2;
|
||||
|
||||
use pkh::changelog::generate_entry;
|
||||
|
||||
use indicatif_log_bridge::LogWrapper;
|
||||
use log::{error, info};
|
||||
|
||||
@@ -178,8 +176,12 @@ fn main() {
|
||||
Command::new("chlog")
|
||||
.about("Auto-generate changelog entry, editing it, committing it afterwards")
|
||||
.arg(arg!(-s --series <series> "Target distribution series").required(false))
|
||||
.arg(arg!(--backport "This changelog is for a backport entry").required(false))
|
||||
.arg(arg!(-v --version <version> "Target version").required(false)),
|
||||
.arg(arg!(--backport "Number the entry as a backport of the target series (1.0-1 becomes 1.0-1~bpo12+1)").required(false)
|
||||
.conflicts_with_all(["nmu", "rebuild"]))
|
||||
.arg(arg!(--nmu "Number the entry as a non-maintainer upload (1.0-1 becomes 1.0-1.1, native 1.0 becomes 1.0+nmu1)").required(false)
|
||||
.conflicts_with("rebuild"))
|
||||
.arg(arg!(--rebuild "Number the entry as a no-change rebuild (1.0-1 becomes 1.0-1build1)").required(false))
|
||||
.arg(arg!(-v --version <version> "Target version (overrides the --backport/--nmu/--rebuild numbering)").required(false)),
|
||||
)
|
||||
.subcommand(
|
||||
Command::new("build")
|
||||
@@ -389,6 +391,23 @@ fn main() {
|
||||
let cwd = current_dir_or_exit();
|
||||
let version = sub_matches.get_one::<String>("version").map(|s| s.as_str());
|
||||
let cli_series = sub_matches.get_one::<String>("series").map(|s| s.as_str());
|
||||
let kind = if sub_matches
|
||||
.get_one::<bool>("backport")
|
||||
.copied()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
pkh::changelog::EntryKind::Backport
|
||||
} else if sub_matches.get_one::<bool>("nmu").copied().unwrap_or(false) {
|
||||
pkh::changelog::EntryKind::Nmu
|
||||
} else if sub_matches
|
||||
.get_one::<bool>("rebuild")
|
||||
.copied()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
pkh::changelog::EntryKind::Rebuild
|
||||
} else {
|
||||
pkh::changelog::EntryKind::Normal
|
||||
};
|
||||
|
||||
// Determine target series: CLI flag > interactive selector > current changelog series
|
||||
let target_series = if let Some(s) = cli_series {
|
||||
@@ -418,12 +437,13 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
let entry = match generate_entry(
|
||||
let entry = match rt.block_on(pkh::changelog::generate_entry(
|
||||
"debian/changelog",
|
||||
Some(&cwd),
|
||||
version,
|
||||
target_series.as_deref(),
|
||||
) {
|
||||
kind,
|
||||
)) {
|
||||
Ok(entry) => entry,
|
||||
Err(e) => {
|
||||
error!("{}", e);
|
||||
@@ -434,6 +454,7 @@ fn main() {
|
||||
"Found package: {}, version: {}",
|
||||
entry.package, entry.previous_version
|
||||
);
|
||||
println!("New version: {}", entry.new_version);
|
||||
println!("Added new changelog entry to {}", entry.path.display());
|
||||
|
||||
let editor = match std::env::var("EDITOR") {
|
||||
|
||||
Reference in New Issue
Block a user