From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yP5ZKnr+wmGSAAAAgWs5BA (envelope-from ) for ; Wed, 22 Dec 2021 11:31:22 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id IAYiJnr+wmHkDAAA1q6Kng (envelope-from ) for ; Wed, 22 Dec 2021 10:31:22 +0000 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 4F1832DDD0 for ; Wed, 22 Dec 2021 11:31:22 +0100 (CET) Received: from localhost ([::1]:44324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzyu1-00077X-Fj for larch@yhetil.org; Wed, 22 Dec 2021 05:31:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzyti-00075y-Kw for guix-patches@gnu.org; Wed, 22 Dec 2021 05:31:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45328) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzyti-0004Ky-Bl for guix-patches@gnu.org; Wed, 22 Dec 2021 05:31:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mzyti-0007kO-9L for guix-patches@gnu.org; Wed, 22 Dec 2021 05:31:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52722] [PATCH v2 1/2] tests: Smarten up git repository testing framework. References: <20211221223244.32542-1-attila@lendvai.name> In-Reply-To: <20211221223244.32542-1-attila@lendvai.name> Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 22 Dec 2021 10:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52722 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52722@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 52722-submit@debbugs.gnu.org id=B52722.164016900529611 (code B ref 52722); Wed, 22 Dec 2021 10:31:02 +0000 Received: (at 52722) by debbugs.gnu.org; 22 Dec 2021 10:30:05 +0000 Received: from localhost ([127.0.0.1]:56866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzysm-0007hT-M0 for submit@debbugs.gnu.org; Wed, 22 Dec 2021 05:30:05 -0500 Received: from mail-ed1-f45.google.com ([209.85.208.45]:35661) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzysl-0007gL-8r for 52722@debbugs.gnu.org; Wed, 22 Dec 2021 05:30:03 -0500 Received: by mail-ed1-f45.google.com with SMTP id y22so6836621edq.2 for <52722@debbugs.gnu.org>; Wed, 22 Dec 2021 02:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=a2QL/succ0L1iXQSgBVoyGo+FGx+7d0CVqqGBXzF8+s=; b=IDxj7Uu7D3GVEFJ6VNFGQ8fHsp1TCaU6Y20LiNkcauzwfVgAY4LurACywiaA2VLdIE LOemTFCTYKGr3YWk0noRbntn1W8L9hTTOqsOXCkHNfaZQ99a7gcejykaY7LXsT8mfYro HXeUyeJb0yhyRQ01BFr+PD3MMYYW+3XvOAg0NhU5aiARTOFtKyYPJOdn8QqdUye+t4pB C94SmHetfW5X9WivqsOlwCzDcTEJ+FUbCvQ0XpVyjwrOKdYhVFVzGilpOfB95ZsMixNF Ptw4aFpOIlbC7FwX7ndm/Wp2VcstHOXpjMI4rD1s+kUlvGfykCdhNe1SiGEGjmnrlWgB eRYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=a2QL/succ0L1iXQSgBVoyGo+FGx+7d0CVqqGBXzF8+s=; b=IZ+z94tidACOe/nh27twkJHskVoDdMX/Hcp5hAGV3G1cfci4/fDi+aqNQF2gFDuFoO +RD8pC2l1SzOLE3AVJgFkXtYkCXbnKotsviBIWLpFmVLXfUcymBpB0sHgn3X75QexMTe kVoBV48xZ0K6LRsUc72om21sZYX04q0gIRinNDnBuEsfXvCB+ZNcWwtm8TRw9Hc0Fng2 6im2xpzHjjPE6jb0KSIxremVplNru5DQ8Ur2my9D8cWHIkxiyVxm0mTY4mw1qGVPitxP b9mtIvuSqP249lB/XwtWqfKNG4shPzIhmHFI5kYAdPlmuEm667qEqCiJO4jKfBJwWWKO TRaA== X-Gm-Message-State: AOAM532Nn749TicVTC0A4DU18xplmgGJKkLdx8w6SE9voqsR11fegarh PLWs7IKfnBm5ItkIQi/+jcS9oVPwTBRP3A== X-Google-Smtp-Source: ABdhPJxjwwsbcuytCvLebtTVmgMNoHooD18r9vhjKtBImzWMH5a9W31uq/Qtx+YG81ZslLoZBe2a/g== X-Received: by 2002:a17:907:8a04:: with SMTP id sc4mr1955465ejc.508.1640168997118; Wed, 22 Dec 2021 02:29:57 -0800 (PST) Received: from lelap.lan (catv-80-99-178-127.catv.broadband.hu. [80.99.178.127]) by smtp.gmail.com with ESMTPSA id cs12sm601840ejc.15.2021.12.22.02.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 02:29:56 -0800 (PST) From: Attila Lendvai Date: Wed, 22 Dec 2021 11:28:55 +0100 Message-Id: <20211222102855.21822-1-attila@lendvai.name> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640169082; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=a2QL/succ0L1iXQSgBVoyGo+FGx+7d0CVqqGBXzF8+s=; b=SumE9wPNPacUctpiMQvqbvSUWT/mZJHTzG4i79ArvVj7lgq5ifJ8Px2rKuPBxUvZU8VyIc LqhUIpAe6Tu1o8/bSnJCyq7LDkiIIwZLe0uNfTtUDO6zb/cdNzdhcNUWbB4/BiC1ezNfLP sOjgPaCFsbKbqT9lZq6BRs8wSxPQ4Xw9M+8KEZUeREW2jhaSjt2bmzY6lc2ONPgg/rGASc 5K9WMZUG77ShTa/HkdJuf92XsvaEXqx+GilQdJ4cn2qIhNLKt6qs6gbTleY/+3tmu5O37N OAwwja/avkCtykC40ns50oBSqAb+gec/cAB95pZhq6WTnqqNsoNLzl/79k5nvQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640169082; a=rsa-sha256; cv=none; b=ls+6j5sYEnnmhMRg3/RuMxcSk/bL1uEMvXfrKtfffawvslCSp/jLAfqpj9I6Oy66dGnYDd GYYpiIQhtQoE9HZppakt74BqbmgzSHxnzrdBZU8mg4h+qhpEY7DJuxlqwgSbKnHff5S3BU 547/F9B7AeRmWnwR8k884avz+wedL475ZDtlw6smazopQ4ThpO+dxoX4HCr/Jxi/Z1yjw0 I5Lj6u52pyOsnP89+d+1EXsoR7KXN8pMs8GWBXPF++HykvwDk+ymIjo1OhjwOr4WIhGVPu YS+TWFsYu71rm/61Pn7dy+lIVxZ/p8z9Ygdl18xFHam8FoQIYVUyUKpUFncmnQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=IDxj7Uu7; dmarc=none; 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" X-Migadu-Spam-Score: -1.54 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=IDxj7Uu7; dmarc=none; 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" X-Migadu-Queue-Id: 4F1832DDD0 X-Spam-Score: -1.54 X-Migadu-Scanner: scn0.migadu.com X-TUID: W4O7VI2KrnWX * guix/tests/git.scm (with-git-repository): New macro, exported. It can be used repeatedly inside a WITH-TEMPORARY-GIT-REPOSITORY. (populate-git-repository): Extend the DSL with (ADD "some-noise"), (RESET "[commit hash]"), (CHECKOUT "branch" ORPHAN). --- as requested on IRC, resending it as two commits. guix/tests/git.scm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/guix/tests/git.scm b/guix/tests/git.scm index 69960284d9..76f5a8b937 100644 --- a/guix/tests/git.scm +++ b/guix/tests/git.scm @@ -26,6 +26,7 @@ (define-module (guix tests git) #:use-module (ice-9 control) #:export (git-command with-temporary-git-repository + with-git-repository find-commit)) (define git-command @@ -59,8 +60,9 @@ (define (git command . args) (apply invoke (git-command) "-C" directory command args))))) - (mkdir-p directory) - (git "init") + (unless (directory-exists? (string-append directory "/.git")) + (mkdir-p directory) + (git "init")) (let loop ((directives directives)) (match directives @@ -78,6 +80,9 @@ (define (git command . args) port))) (git "add" file) (loop rest))) + ((('add file-name-and-content) rest ...) + (loop (cons `(add ,file-name-and-content ,file-name-and-content) + rest))) ((('remove file) rest ...) (git "rm" "-f" file) (loop rest)) @@ -99,12 +104,18 @@ (define (git command . args) ((('checkout branch) rest ...) (git "checkout" branch) (loop rest)) + ((('checkout branch 'orphan) rest ...) + (git "checkout" "--orphan" branch) + (loop rest)) ((('merge branch message) rest ...) (git "merge" branch "-m" message) (loop rest)) ((('merge branch message ('signer fingerprint)) rest ...) (git "merge" branch "-m" message (string-append "--gpg-sign=" fingerprint)) + (loop rest)) + ((('reset to) rest ...) + (git "reset" "--hard" to) (loop rest))))) (define (call-with-temporary-git-repository directives proc) @@ -121,6 +132,14 @@ (define-syntax-rule (with-temporary-git-repository directory (lambda (directory) exp ...))) +(define-syntax-rule (with-git-repository directory + directives exp ...) + "Evaluate EXP in a context where DIRECTORY is (further) populated as +per DIRECTIVES." + (begin + (populate-git-repository directory directives) + exp ...)) + (define (find-commit repository message) "Return the commit in REPOSITORY whose message includes MESSAGE, a string." (let/ec return -- 2.34.0