From 1500e541f2cfab89e2fb847411e056df1e8e50fb Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 2 Jun 2025 11:13:03 -0400 Subject: [PATCH] diff-closures: use removed / added words --- src/nix/diff-closures.cc | 7 ++++++- tests/functional/nix-profile.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nix/diff-closures.cc b/src/nix/diff-closures.cc index ecfc907be..fa3d51ae7 100644 --- a/src/nix/diff-closures.cc +++ b/src/nix/diff-closures.cc @@ -97,8 +97,13 @@ void printClosureDiff( if (showDelta || !removed.empty() || !added.empty()) { std::vector items; - if (!removed.empty() || !added.empty()) + if (!removed.empty() && !added.empty()) { items.push_back(fmt("%s → %s", showVersions(removed), showVersions(added))); + } else if (!removed.empty()) { + items.push_back(fmt("%s removed", showVersions(removed))); + } else if (!added.empty()) { + items.push_back(fmt("%s added", showVersions(added))); + } if (showDelta) items.push_back(fmt("%s%+.1f KiB" ANSI_NORMAL, sizeDelta > 0 ? ANSI_RED : ANSI_GREEN, sizeDelta / 1024.0)); logger->cout("%s%s: %s", indent, name, concatStringsSep(", ", items)); diff --git a/tests/functional/nix-profile.sh b/tests/functional/nix-profile.sh index 7afde40a7..a96abbbdf 100755 --- a/tests/functional/nix-profile.sh +++ b/tests/functional/nix-profile.sh @@ -58,7 +58,7 @@ nix profile list | grep -A4 'Name:.*flake1' | grep 'Locked flake URL:.*narHash' [ -e $TEST_HOME/.nix-profile/share/man ] (! [ -e $TEST_HOME/.nix-profile/include ]) nix profile history -nix profile history | grep "packages.$system.default: 1.0 added" +nix profile history | grep "packages.$system.default: 1.0, 1.0-man added" nix profile diff-closures | grep 'env-manifest.nix: (no version) removed' # Test XDG Base Directories support