chlog: cap the no-tag history search with --limit

Without a version tag, the boundary of a new entry was found by walking
the whole history and diffing each commit's tree against the changelog
path. On large repositories that per-commit tree diff takes 10+ minutes.

Add --limit (default 500, 0 = unlimited) capping that walk: when no
changelog commit is found within the last N commits, the oldest visited
commit becomes the boundary — the version tag probe is skipped there,
since it could jump the boundary arbitrarily far back and defeat the
cap — and a warning explains the fallback. A found version tag still
takes precedence and is unaffected by the limit.
This commit is contained in:
2026-09-29 12:02:43 +02:00
parent e7cad0b1ca
commit babddad505
3 changed files with 264 additions and 16 deletions
+8 -1
View File
@@ -328,7 +328,9 @@ fn main() {
.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)),
.arg(arg!(-v --version <version> "Target version (overrides the --backport/--nmu/--rebuild numbering)").required(false))
.arg(arg!(--limit <n> "Cap how far back the history is searched for the previous changelog entry when no version tag exists (0 = unlimited)").required(false)
.value_parser(clap::value_parser!(usize)).default_value("500")),
)
.subcommand(
Command::new("build")
@@ -661,6 +663,10 @@ fn main() {
info!("Done.");
}
Some(("chlog", sub_matches)) => {
let history_limit = sub_matches
.get_one::<usize>("limit")
.copied()
.unwrap_or(500);
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());
@@ -719,6 +725,7 @@ fn main() {
version,
target_series.as_deref(),
kind,
history_limit,
)) {
Ok(entry) => entry,
Err(e) => {