From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IPROHxOP2GW3hAEAqHPOHw:P1 (envelope-from ) for ; Fri, 23 Feb 2024 13:26:59 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id IPROHxOP2GW3hAEAqHPOHw (envelope-from ) for ; Fri, 23 Feb 2024 13:26:59 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mailbox.org header.s=mail20150812 header.b=fUWEd6W9; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1708691219; h=from:from:sender:sender:reply-to: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:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=goDFmOhnrVlO6ep7DC3M9ouGOa0HDenPpXJtChv3UZA=; b=H3Kwsf57GeH1H5EeaP/YFq553TvKe249NOjJYxoi6apxCFZcDTla/0ShiNFpwXixFlhsCg tUswMF5u35+JIb5ZO019ilTeSSRSzzgTddFIdzUY4ckwxBEA/uoJ/p7Z70+KxeyIj8al+1 dBSIbk3zWJkaaVfOkXLVF9ZWiYDGoK96/mQQOq0tXrQBsjIt7PFo8h2JUsZRYMRZDOiIzg fMMGFTQKJE9injRVBDcGFjgr/32dVryXw6PbIKkWxpscy9SFA2HeL0p/HPsRISWE8fjeS2 XAynQEubyeoSheveWPAXvNGLB/2+NpOa75sRP25Jk0+bLBIs+d178mrsgueboA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mailbox.org header.s=mail20150812 header.b=fUWEd6W9; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1708691219; a=rsa-sha256; cv=none; b=jWPUnw2DcYRjspLt8lFx1dJ0q02unECoVPdiVzmk2IguQBKNW9cjml8thXUAuz/KZwzlPf Dgftn+jpqXqX5r2+l6x2wO99kUt9ulX3DTlQaZzXv3chzKAFaO8vJbbZhEdMc41tvaSDH4 afFvUtTXaRlse3uY8u7+8tsh7ZQgpZo45TxqH8Je8Za05VvOebDPjx9ZtmpZwfewsILh/f 3Ry/Yvv/9eFOafYx6Lo89f3oaZz6uSNcJRdu9LOwwvKdoQn76czRPFxyvnlHhdcMSmMVVh P491ESL6iO+519tHkOfuqaelbBTTzqkUVaFo/omB+YC2NODVInBdAjSo9jWhJg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 122FD584BD for ; Fri, 23 Feb 2024 13:26:59 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdUdU-00025I-Lj; Fri, 23 Feb 2024 07:26:40 -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 ) id 1rdUcV-00089v-Vw for guix-patches@gnu.org; Fri, 23 Feb 2024 07:25:40 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdUcV-0000Z9-L7 for guix-patches@gnu.org; Fri, 23 Feb 2024 07:25:39 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rdUcs-0000qA-OM for guix-patches@gnu.org; Fri, 23 Feb 2024 07:26:02 -0500 X-Loop: help-debbugs@gnu.org 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?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 23 Feb 2024 12:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69324 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69324@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@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 ) id 1rdUc6-0000ns-W5 for submit@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 ) id 1rdUKq-0008Qn-U2 for submit@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 ) id 1rdUKS-0005ze-Sx for guix-patches@gnu.org; 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 ) id 1rdUKN-0003z2-By for guix-patches@gnu.org; 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 ; 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: Date: Fri, 23 Feb 2024 13:06:33 +0100 MIME-Version: 1.0 Content-Language: en-US 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@mailbox.org; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: =?UTF-8?Q?Tom=C3=A1s_?= =?UTF-8?Q?Ort=C3=ADn?= X-ACL-Warn: , =?utf-8?q?Tom=C3=A1s_Ort=C3=ADn_via_Guix-patches?= From: =?utf-8?q?Tom=C3=A1s_Ort=C3=ADn_via_Guix-patches?= via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -7.17 X-Spam-Score: -7.17 X-Migadu-Queue-Id: 122FD584BD X-Migadu-Scanner: mx11.migadu.com X-TUID: 4aNb/9wMoyy7 * 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 ;;; Copyright © 2022 Arun Isaac ;;; Copyright © 2022 Antero Mejr +;;; Copyright © 2024 Tomás Ortín Fernández ;;; ;;; 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 ;;; Copyright © 2022 Taiju HIGASHI ;;; Copyright © 2022 Liliana Marie Prikler +;;; Copyright © 2024 Tomás Ortín Fernández ;;; ;;; 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