From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 2Ik/CXMYC2Yq/AAAe85BDQ:P1 (envelope-from ) for ; Mon, 01 Apr 2024 22:26:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 2Ik/CXMYC2Yq/AAAe85BDQ (envelope-from ) for ; Mon, 01 Apr 2024 22:26:27 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=CU5Oip6k; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1712003186; a=rsa-sha256; cv=none; b=pI1Fvkl2oG/8tOZUvM6edqG+gpK/Ht5KLfHgRJxM8ZsmYR4VozI7L5LPiLWs9k5Ng39JkR EQ7ReqoVQFc5nB3a/tCZeeIw/yT3us4Df/sRG7tfRS+CUKSZZSsH58CskIWUbwq/lfYavT KJSTEQhOjm1kjXay5nhfnxOZIaTaXG8jlxVQfENfibHWrB25U4jCFHSOqHt3gZVoN2sRBn fMTOFQPkiX+1YJdN8P3aVVDPMpzul6LgA9M6UNCGoVZVI+Rilyyuv1YWhIpDm+ov9ZguY/ CJlxTH6DmO8JtJBJt950Pr2MmfiNFMOaWrnPARSfIRnYch0eL2DOhOlN8aMYag== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=CU5Oip6k; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1712003186; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=jnPjGJ0K3R62W91yhymu2cQDh5GvroPIaGSYOfwFkWI=; b=uz68LcNMv2x1/UXbC8+o+0tbVSFdLKv+lzLTZJMQeiiWB/6abOI11/UvOhFtZnTHsWpskR lLb5T5yUCEH+rLW8rWmVtdfkwZ5KpvsBJ0jSLpQUc5swqhlxIG6n5XOAyPhOcWHXUbXN7i efHknXc36/oR8r2VAS9l7WZIyhirVa/ISQbdDoDgvgAqX1bUM6TLQpYSXcj5ymH8Fd43+x jN8A5c5XOZ2HVfBCIKiDbBKLSoydmPkc/qJ/w8BtIcvYfAbiejdcD/noLK/SIKMwf6tyx0 q+tNLJ5Z5+yVm2NS3Z99Br+dlA9ltIGxfKuxqQ2kf91XaVg9O4EMoeG0j5HvAw== 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 BF38C1B849 for ; Mon, 1 Apr 2024 22:26:26 +0200 (CEST) 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?Q?=E2=80=98tag->commit=E2=80=99?= 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 Content-Type: text/plain; charset=UTF-8 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Spam-Score: -4.55 X-Migadu-Queue-Id: BF38C1B849 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -4.55 X-TUID: 4pFLsKNiyCcg * 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 -- 2.41.0