>> I think we should change ‘--list-generations’ to not output the zeroth >> generation. Even though it could be present in the profile, users >> shouldn’t be concerned about it.
> Agreed. Can I push these patches to ‘master’? Should I document that the zeroth generation is always ignored?
From 7fc042876bf00031d6b36b8d697984ce1ee1700e Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov <nik...@karetnikov.org> Date: Mon, 23 Sep 2013 22:56:21 +0000 Subject: [PATCH 1/3] tests: Test that '--list-generations' may not output anything. --- tests/guix-package.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/guix-package.sh b/tests/guix-package.sh index b09a9c0..e2c0374 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -85,6 +85,9 @@ then test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ = " guile-bootstrap" + # Do not output anything when a generation does not exist. + test -z "`guix package -p "$profile" -l 42`" + # Remove a package. guix package --bootstrap -p "$profile" -r "guile-bootstrap" test -L "$profile-3-link" -- 1.7.9.5
From ac4c69fea488e4028f3957986104159fca467ecb Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov <nik...@karetnikov.org> Date: Mon, 23 Sep 2013 23:31:15 +0000 Subject: [PATCH 2/3] guix package: Do not list the zeroth generation. * guix/scripts/package.scm(guix-package)[process-query]: Change 'list-generation' to not list the zeroth generation. * tests/guix-package.sh: Test it. --- guix/scripts/package.scm | 35 ++++++++++++++++++----------------- tests/guix-package.sh | 3 +++ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 1d00e39..9ed499d 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -955,23 +955,24 @@ more information.~%")) (match (assoc-ref opts 'query) (('list-generations pattern) (define (list-generation number) - (begin - (format #t (_ "Generation ~a\t~a~%") number - (date->string - (time-utc->date - (generation-time profile number)) - "~b ~d ~Y ~T")) - (for-each (match-lambda - ((name version output location _) - (format #t " ~a\t~a\t~a\t~a~%" - name version output location))) - - ;; Show most recently installed packages last. - (reverse - (manifest-packages - (profile-manifest - (format #f "~a-~a-link" profile number))))) - (newline))) + (or (zero? number) + (begin + (format #t (_ "Generation ~a\t~a~%") number + (date->string + (time-utc->date + (generation-time profile number)) + "~b ~d ~Y ~T")) + (for-each (match-lambda + ((name version output location _) + (format #t " ~a\t~a\t~a\t~a~%" + name version output location))) + + ;; Show most recently installed packages last. + (reverse + (manifest-packages + (profile-manifest + (format #f "~a-~a-link" profile number))))) + (newline)))) (cond ((not (file-exists? profile)) ; XXX: race condition (leave (_ "profile '~a' does not exist~%") diff --git a/tests/guix-package.sh b/tests/guix-package.sh index e2c0374..b4bd414 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -110,6 +110,9 @@ then test "`readlink_base "$profile"`" = "$profile-0-link" done + # Test that '--list-generations' does not output the zeroth generation. + test -z "`guix package -p "$profile" -l 0`" + # Reinstall after roll-back to the empty profile. guix package --bootstrap -p "$profile" -e "$boot_make" test "`readlink_base "$profile"`" = "$profile-1-link" -- 1.7.9.5
From 64b01b6414d42b9b495059223e5312d9d01ba860 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov <nik...@karetnikov.org> Date: Tue, 24 Sep 2013 00:36:51 +0000 Subject: [PATCH 3/3] tests: Use 'test -z' to check that a string equals zero. --- tests/guix-package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/guix-package.sh b/tests/guix-package.sh index b4bd414..2b8b146 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -79,7 +79,7 @@ then # Search. test "`guix package -s "An example GNU package" | grep ^name:`" = \ "name: hello" - test "`guix package -s "n0t4r341p4ck4g3"`" = "" + test -z "`guix package -s "n0t4r341p4ck4g3"`" # List generations. test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ -- 1.7.9.5
pgpB8BjyP1In0.pgp
Description: PGP signature