X-Loop: help-debbugs@HIDDEN
Subject: [bug#69324] [PATCH] scripts: package: Make an argument for '--delete-generations' mandatory
Resent-From: =?UTF-8?Q?Tom=C3=A1s_?= =?UTF-8?Q?Ort=C3=ADn?= <tomasortin@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Fri, 23 Feb 2024 12:26:02 +0000
Resent-Message-ID: <handler.69324.B.17086911163102 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 69324
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 69324 <at> debbugs.gnu.org
X-Debbugs-Original-To: guix-patches@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.17086911163102
(code B ref -1); Fri, 23 Feb 2024 12:26:02 +0000
Received: (at submit) by debbugs.gnu.org; 23 Feb 2024 12:25:16 +0000
Received: from localhost ([127.0.0.1]:35473 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1rdUc6-0000ns-W5
for submit <at> debbugs.gnu.org; Fri, 23 Feb 2024 07:25:16 -0500
Received: from lists.gnu.org ([209.51.188.17]:51966)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <tomasortin@HIDDEN>) id 1rdUKq-0008Qn-U2
for submit <at> debbugs.gnu.org; Fri, 23 Feb 2024 07:07:26 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <tomasortin@HIDDEN>)
id 1rdUKS-0005ze-Sx
for guix-patches@HIDDEN; Fri, 23 Feb 2024 07:07:00 -0500
Received: from mout-p-102.mailbox.org ([2001:67c:2050:0:465::102])
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256)
(Exim 4.90_1) (envelope-from <tomasortin@HIDDEN>)
id 1rdUKN-0003z2-By
for guix-patches@HIDDEN; Fri, 23 Feb 2024 07:07:00 -0500
Received: from smtp202.mailbox.org (smtp202.mailbox.org
[IPv6:2001:67c:2050:b231:465::202])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
(No client certificate requested)
by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Th7yz1vLDz9smk
for <guix-patches@HIDDEN>; Fri, 23 Feb 2024 13:06:35 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
s=mail20150812; t=1708689995;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding;
bh=goDFmOhnrVlO6ep7DC3M9ouGOa0HDenPpXJtChv3UZA=;
b=fUWEd6W9JiFlPUV5Jq8yraB3TNlH0i1geOPgIsJEevivfeIWr8w9xNPXehjQoPyWtMvs4O
+vDG4ZylxKuGDKUdCDQJR9z+zykegzMeK3DaiFX1BlEBcsV3XbzDGO4udS7dgONWq8vvoA
IdEOWBhqgE9RlZAIvY3BPXQnLZ+M1xwnQoV5t3EC2ZmoXz5fZMPZlVXYQaFK9GKGe/Vs9T
kXHYcX75eqzi4hLbhQ/wRIsCBMXrzEajfoiD06bBznVQCTaw352qu987/Jjosk+xdI4wTO
c+SsgSq6BfTVMr/bdKSqeOMQbBaLrcmc5KA6pf+M/J8yxExwgpeJ6WCMh2aA7g==
Message-ID: <cbff10f8-5eaa-b46a-851c-7de79f8fec23@HIDDEN>
Date: Fri, 23 Feb 2024 13:06:33 +0100
MIME-Version: 1.0
Content-Language: en-US
From: =?UTF-8?Q?Tom=C3=A1s_?= =?UTF-8?Q?Ort=C3=ADn?= <tomasortin@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-MBO-RS-META: 5sgcwahikwzo1z3b3pmod9qik4pc6tnt
X-MBO-RS-ID: df11a68019b56da78d8
Received-SPF: pass client-ip=2001:67c:2050:0:465::102;
envelope-from=tomasortin@HIDDEN; helo=mout-p-102.mailbox.org
X-Spam_score_int: -23
X-Spam_score: -2.4
X-Spam_bar: --
X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1,
DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)
* guix/scripts/package.scm (delete-matching-generations): Ensure
'pattern' is always a string
* guix/ui.scm (string->generations): Add '..' as syntax to delete all
previous generations
* guix/ui.scm (matching-generations): Handle case of empty pattern
Recently, I've been bitten by mistyping 'guix package -d' without
specifying any pattern. To my surprise, this results in all previous
generations being deleted without any kind of confirmation. This is a
quite easy mistake to make, so it seems like a footgun.
This change makes it mandatory to specify an argument to 'guix package
--delete-generations'. Complete deletion of old generations is now
required to be explicit. In line with the existing pattern syntax, 'guix
package --delete-generations ..' now deletes all previous generations.
Change-Id: Ia51b33886a25661cea47aef56966cf1a3bfa7658
---
guix/scripts/package.scm | 4 +++-
guix/ui.scm | 9 +++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index a489e06e73..c4a096fafe 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -13,6 +13,7 @@
;;; Copyright © 2022 Josselin Poiret <dev@HIDDEN>
;;; Copyright © 2022 Arun Isaac <arunisaac@HIDDEN>
;;; Copyright © 2022 Antero Mejr <antero@HIDDEN>
+;;; Copyright © 2024 Tomás Ortín Fernández <tomasortin@HIDDEN>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -109,7 +110,8 @@ (define (delete-matching-generations store profile
pattern)
a string denoting a set of generations: the empty list means \"all
generations
but the current one\", a number designates a generation, and other
patterns
denote ranges as interpreted by 'matching-generations'."
- (let ((current (generation-number profile)))
+ (let ((current (generation-number profile))
+ (pattern (if pattern pattern ""))) ; ensure pattern is a string
(cond ((not (file-exists? profile)) ; XXX: race condition
(raise (condition (&profile-not-found-error
(profile profile)))))
diff --git a/guix/ui.scm b/guix/ui.scm
index 962d291d2e..723f53946a 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -19,6 +19,7 @@
;;; Copyright © 2018 Steve Sprang <scs@HIDDEN>
;;; Copyright © 2022 Taiju HIGASHI <higashi@HIDDEN>
;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@HIDDEN>
+;;; Copyright © 2024 Tomás Ortín Fernández <tomasortin@HIDDEN>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1850,7 +1851,7 @@ (define* (display-search-results matches port
(define (string->generations str)
"Return the list of generations matching a pattern in STR. This
function
-accepts the following patterns: \"1\", \"1,2,3\", \"1..9\", \"1..\",
\"..9\"."
+accepts the following patterns: \"1\", \"1,2,3\", \"1..9\", \"1..\",
\"..9\", \"..\"."
(define (maybe-integer)
(let ((x (string->number str)))
(and (integer? x)
@@ -1869,6 +1870,7 @@ (define (string->generations str)
((maybe-comma-separated-integers)
=>
identity)
+ ((string= ".." str) '(>= 0))
((string-match "^([0-9]+)\\.\\.([0-9]+)$" str)
=>
(lambda (match)
@@ -1987,7 +1989,10 @@ (define* (matching-generations str profile
filter-by-duration)
(else
(raise
- (formatted-message (G_ "invalid syntax: ~a~%") str)))))
+ (formatted-message (G_ "invalid syntax: ~a~%")
+ (if (string= "" str)
+ "pattern missing"
+ str))))))
(define (display-generation profile number)
"Display a one-line summary of generation NUMBER of PROFILE."
base-commit: aefc7428203203ae88c64cc4769113453c01a185
--
2.41.0
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: =?UTF-8?Q?Tom=C3=A1s_?= =?UTF-8?Q?Ort=C3=ADn?= <tomasortin@HIDDEN> Subject: bug#69324: Acknowledgement ([PATCH] scripts: package: Make an argument for '--delete-generations' mandatory) Message-ID: <handler.69324.B.17086911163102.ack <at> debbugs.gnu.org> References: <cbff10f8-5eaa-b46a-851c-7de79f8fec23@HIDDEN> X-Gnu-PR-Message: ack 69324 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 69324 <at> debbugs.gnu.org Date: Fri, 23 Feb 2024 12:26:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): guix-patches@HIDDEN If you wish to submit further information on this problem, please send it to 69324 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 69324: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D69324 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN
Subject: [bug#69324] (no subject)
References: <cbff10f8-5eaa-b46a-851c-7de79f8fec23@HIDDEN>
In-Reply-To: <cbff10f8-5eaa-b46a-851c-7de79f8fec23@HIDDEN>
Resent-From: =?UTF-8?Q?Tom=C3=A1s_?= =?UTF-8?Q?Ort=C3=ADn?= <tomasortin@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Wed, 13 Nov 2024 12:34:02 +0000
Resent-Message-ID: <handler.69324.B69324.173150121618206 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 69324
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 69324 <at> debbugs.gnu.org
Received: via spool by 69324-submit <at> debbugs.gnu.org id=B69324.173150121618206
(code B ref 69324); Wed, 13 Nov 2024 12:34:02 +0000
Received: (at 69324) by debbugs.gnu.org; 13 Nov 2024 12:33:36 +0000
Received: from localhost ([127.0.0.1]:41160 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1tBCYx-0004ja-OX
for submit <at> debbugs.gnu.org; Wed, 13 Nov 2024 07:33:36 -0500
Received: from mout-p-201.mailbox.org ([80.241.56.171]:46452)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <tomasortin@HIDDEN>) id 1tBCYw-0004j9-1F
for 69324 <at> debbugs.gnu.org; Wed, 13 Nov 2024 07:33:35 -0500
Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
(No client certificate requested)
by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4XpN445mdzz9shP
for <69324 <at> debbugs.gnu.org>; Wed, 13 Nov 2024 13:33:24 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
s=mail20150812; t=1731501204;
h=from:from:reply-to:subject:date:date:message-id:message-id:to:to:cc:
mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding;
bh=budPBHDMT0yfZjwBRaBG72yXQl/CJAUsch5jjfl4ESU=;
b=gaTr2GuVCikgQ8G+46kDc/+tx58GsyUROxgKfEIE3es38ykKuoVwpBiALKmRy5qn7rUXJB
JmASbrw2ZlFAOqCSnNzfFIKD/TPxrnbb06q048Z2Ic/II86OHJetlJSMPCUOVc0T9NWHBi
DlddfZ4A9lAg2seRvlKGiwEDrTW/gg9y7rsLNQL76VXG3FFqlTcKrB7IIiRmKYe0o5H8rD
x9TA2JdmXHDPBRz3FmZsQyu4vDWtNefpE/nj0HM60Mg4AMKe6krZcCG7LwM1r6ozymfn9L
/9E6G/1umdXEd9hSkormuoSS+nnVVVP93wyyiqZHjW/6E8R18rNZWJQYKhxIBA==
Message-ID: <0c41fca1-55c9-4409-8e4b-bad6dee47703@HIDDEN>
Date: Wed, 13 Nov 2024 14:33:23 +0200
MIME-Version: 1.0
Content-Language: en-US
From: =?UTF-8?Q?Tom=C3=A1s_?= =?UTF-8?Q?Ort=C3=ADn?= <tomasortin@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-MBO-RS-META: acs87m6htcpzr8mbcmdj19kdhoxkmznr
X-MBO-RS-ID: f102c9b93f0690aad24
X-Spam-Score: 1.3 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
has NOT identified this incoming email as spam. The original
message has been attached to this so you can view it or label
similar future email. If you have any questions, see
the administrator of that system for details.
Content preview: I see the patch has not been merged,
is the reason the implementation or the UX change itself?
Content analysis details: (1.3 points, 10.0 required)
pts rule name description
---- ---------------------- --------------------------------------------------
0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE:
The query to Validity was blocked. See
https://knowledge.validity.com/hc/en-us/articles/20961730681243
for more information.
[80.241.56.171 listed in sa-accredit.habeas.com]
0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The
query to Validity was blocked. See
https://knowledge.validity.com/hc/en-us/articles/20961730681243
for more information.
[80.241.56.171 listed in bl.score.senderscore.com]
0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record
-0.0 SPF_PASS SPF: sender matches SPF record
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/,
low trust [80.241.56.171 listed in list.dnswl.org]
1.8 MISSING_SUBJECT Missing Subject: header
0.2 NO_SUBJECT Extra score for no subject
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)
I see the patch has not been merged, is the reason the implementation or
the UX change itself?
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.