fix: refuse "--dupkeep 0" (#2807)
Some checks failed
Install / install (ubuntu-latest) (push) Has been cancelled
Nix / check (push) Has been cancelled
Nix / build-test (push) Has been cancelled
Codespell / Check for spelling errors (push) Has been cancelled
build-docker / publish_x86 (push) Has been cancelled
build-docker / publish_aarch64 (push) Has been cancelled
Install / install (macos-14) (push) Has been cancelled
Rust / build (macos-14) (push) Has been cancelled
Rust / build (ubuntu-latest) (push) Has been cancelled
Rust / cross-compile (x86_64-unknown-illumos) (push) Has been cancelled
Rust / unit-test (macos-14) (push) Has been cancelled
Rust / unit-test (ubuntu-latest) (push) Has been cancelled
Rust / check (macos-14) (push) Has been cancelled
Rust / check (ubuntu-latest) (push) Has been cancelled
Rust / integration-test (push) Has been cancelled
Rust / clippy (push) Has been cancelled
Rust / format (push) Has been cancelled
Shellcheck / shellcheck (push) Has been cancelled
build-docker / publish_manifest (push) Has been cancelled

People may think it would keep only one copy, but it didn't work that way.
This commit is contained in:
依云 2025-07-03 23:35:18 +08:00 committed by GitHub
parent 2741338a14
commit 58e307bc6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -622,6 +622,13 @@ impl Cmd {
dupkeep: u32,
dry_run: bool,
) -> Result<()> {
if dupkeep == 0 {
eprintln!(
"\"--dupkeep 0\" would keep 0 copies of duplicate commands and thus delete all of them! Use \"atuin search --delete ...\" if you really want that."
);
std::process::exit(1);
}
let matches: Vec<History> = db.get_dups(before, dupkeep).await?;
match matches.len() {