From patchwork Mon Apr 1 20:25:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 62441 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C162327BBE9; Mon, 1 Apr 2024 21:26:27 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A479127BBEA for ; Mon, 1 Apr 2024 21:26:26 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrOEU-000854-Id; Mon, 01 Apr 2024 16:26:20 -0400 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 1rrOEE-00082i-C2 for guix-patches@gnu.org; Mon, 01 Apr 2024 16:26:02 -0400 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 1rrOED-0006on-VA; Mon, 01 Apr 2024 16:26:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rrOEG-0007HX-0I; Mon, 01 Apr 2024 16:26:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70132] [PATCH 04/11] git: Add =?utf-8?b?4oCYdGFnLT5jb21taXQ=?= =?utf-8?b?4oCZ?= and use it in (guix channels). Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Mon, 01 Apr 2024 20:26:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70132 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70132@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 70132-submit@debbugs.gnu.org id=B70132.171200316227950 (code B ref 70132); Mon, 01 Apr 2024 20:26:03 +0000 Received: (at 70132) by debbugs.gnu.org; 1 Apr 2024 20:26:02 +0000 Received: from localhost ([127.0.0.1]:51661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrOED-0007GS-Le for submit@debbugs.gnu.org; Mon, 01 Apr 2024 16:26:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrOEB-0007G8-B1 for 70132@debbugs.gnu.org; Mon, 01 Apr 2024 16:25:59 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rrOE2-0006mP-LR; Mon, 01 Apr 2024 16:25:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=jnPjGJ0K3R62W91yhymu2cQDh5GvroPIaGSYOfwFkWI=; b=CU5Oip6knmLkTm0/plRA 8PPA3VaNNWTJxvHHPWnNzjyPR6z2ymjM9Q7NTS/6mPTkfMaqUVmgCTqgXH+TZXjbO/qz5G6skaUgj Z5hDvBGy65UW0OrUSA1R6Y0cKe4EqSMQ+ITUlEfer/xAk/+9KN1lqvHhpxsgllF6KBsn127f5OrRg /eysM5phmcxZK10gQmKroTpKJR6JbkPlUtJLvCCawzQZKYr2B5SKG1j5QZ2aFGsYPuEUkxc9uaAWq R9KGhdo0wXa6qibUP2Y9nJ0T02btqRaj7AV0RWlWWsN6kDJvPUloQbPnFEn78uFFT3aAdYqqKCjpl LbWO79Lnml8zEg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 1 Apr 2024 22:25:16 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/git.scm (tag->commit): New procedure, taken from… (resolve-reference): … here. Use it in the ‘tag’ case. * guix/channels.scm (resolve-channel-news-entry-tag): Use ‘tag->commit’ instead of custom code. Change-Id: I46ea387345dc1b695ce0702991a52d0cde29e2f0 --- guix/channels.scm | 11 +++-------- guix/git.scm | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/guix/channels.scm b/guix/channels.scm index 0b776ab211..70608561f9 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -26,6 +26,7 @@ (define-module (guix channels) commit-difference repository-info commit-short-id + tag->commit with-repository) #:autoload (guix git-authenticate) (authenticate-repository) #:autoload (guix openpgp) (openpgp-public-key-fingerprint @@ -1148,14 +1149,8 @@ (define (resolve-channel-news-entry-tag repository entry) cannot be found." (if (channel-news-entry-commit entry) entry - (let* ((tag (channel-news-entry-tag entry)) - (reference (reference-lookup repository - (string-append "refs/tags/" tag))) - (target (reference-target reference)) - (oid (let ((obj (object-lookup repository target))) - (if (= OBJ-TAG (object-type obj)) ;annotated tag? - (tag-target-id (tag-lookup repository target)) - target)))) + (let* ((tag (channel-news-entry-tag entry)) + (oid (object-id (tag->commit repository tag)))) (channel-news-entry (oid->string oid) tag (channel-news-entry-title entry) (channel-news-entry-body entry))))) diff --git a/guix/git.scm b/guix/git.scm index eab84ea798..8e1d863976 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -68,6 +68,7 @@ (define-module (guix git) commit-descendant? commit-id? commit-short-id + tag->commit remote-refs @@ -237,6 +238,19 @@ (define (commit-id? str) (define commit-short-id (compose (cut string-take <> 7) oid->string commit-id)) +(define (tag->commit repository tag) + "Resolve TAG in REPOSITORY and return the corresponding object, usually a +commit." + (let* ((oid (reference-name->oid repository + (string-append "refs/tags/" tag))) + (obj (object-lookup repository oid))) + ;; OID may designate an "annotated tag" object or a "commit" object. + ;; Return the commit object in both cases. + (if (= OBJ-TAG (object-type obj)) + (object-lookup repository + (tag-target-id (tag-lookup repository oid))) + obj))) + (define (resolve-reference repository ref) "Resolve the branch, commit or tag specified by REF, and return the corresponding Git object." @@ -283,15 +297,7 @@ (define (resolve-reference repository ref) ;; There's no such tag, so it must be a commit ID. (resolve `(commit . ,str))))))) (('tag . tag) - (let* ((oid (reference-name->oid repository - (string-append "refs/tags/" tag))) - (obj (object-lookup repository oid))) - ;; OID may designate an "annotated tag" object or a "commit" object. - ;; Return the commit object in both cases. - (if (= OBJ-TAG (object-type obj)) - (object-lookup repository - (tag-target-id (tag-lookup repository oid))) - obj)))))) + (tag->commit repository tag))))) (define (switch-to-ref repository ref) "Switch to REPOSITORY's branch, commit or tag specified by REF. Return the