From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.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 KNC8CXkYC2ajKQAAe85BDQ:P1 (envelope-from ) for ; Mon, 01 Apr 2024 22:26:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id KNC8CXkYC2ajKQAAe85BDQ (envelope-from ) for ; Mon, 01 Apr 2024 22:26:33 +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=HkXjTA1K; 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=1712003193; 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=y2ykFhnttS1YRD6bIrNyjtgMcfA+SjyDkZ4r96dbuu4=; b=R/0k1RN9A6fQmhqBIksfrQdJRma0coDP1VtYv6mxe92QMs0X2KLQ30aUGtn2dSBdDZt4e+ mkz45okV0oRbGePlkOL1sBcdFCkUScCA32Hm/ygVIhhbufUVoyHz9PvzZ1DC/UQWfIEYMc 2EJWDGOxqf6R1DU5hLb12Q2JquXKpJqYNfwdJpn5vOaxAxvmb3ICgiTFmIwl5l+cczngtu 5heShusa6pjqM1D07iLa+XLQbteShrl0FprTFCMpy2VPlJvGp1/dy3+/RpEjEZ+rQjUOF8 WX4irfvhnfFc7se0jq/ISk44xOjFMGzlTod9gkcr7gCSCz6ezYeIAC9waVdtyw== 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=HkXjTA1K; 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=1712003193; a=rsa-sha256; cv=none; b=gsGX2pSlPgpBVs+LZ1DML4x2jpscqMk1u1392p8p3xfd9F5YxexPWF/fkP35H6jd244zub 7jeMSadCgmr0rvym0229rGG1DVM80XZChduxEki7P3jmXwLhtPIeDmPX4KrnwoFf3o+2Y2 Dfam4NQnKQOG4SZAR2Y0mcHfBMpiSudPheB+BjmkWhhGFJZCcUJ3g9PE9GdVEdqybSSM5l PRh3MLlPAHol34+ttrKjwwf8O11KW1XdLLUQpSYqaShSns4Rc3k4FIunTCV7yhGAWBoQMa aBExTsWS4j8UnXeG+pkBQ/g6wlT25RbSPjKlzxRgXgGsvkOeoPceMuQQb7rWpQ== 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 D6CA462ACF for ; Mon, 01 Apr 2024 22:26:32 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrOEa-00088w-N3; Mon, 01 Apr 2024 16:26:24 -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-00082j-CH 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 1rrOEE-0006oo-0J; 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 1rrOEE-0007H3-U5; Mon, 01 Apr 2024 16:26:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70132] [PATCH 02/11] git: Add =?UTF-8?Q?=E2=80=98repository-info=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:02 +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.171200315227897 (code B ref 70132); Mon, 01 Apr 2024 20:26:02 +0000 Received: (at 70132) by debbugs.gnu.org; 1 Apr 2024 20:25:52 +0000 Received: from localhost ([127.0.0.1]:51653 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrOE3-0007Fp-PD for submit@debbugs.gnu.org; Mon, 01 Apr 2024 16:25:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrOE2-0007FS-AZ for 70132@debbugs.gnu.org; Mon, 01 Apr 2024 16:25:50 -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 1rrODt-0006lf-MR; Mon, 01 Apr 2024 16:25:41 -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=y2ykFhnttS1YRD6bIrNyjtgMcfA+SjyDkZ4r96dbuu4=; b=HkXjTA1KSt9c558bMmDj 2nLTosaA9GQFt5Uz4GR4orb4WgJMqn4I/SoZKx1wJHmTUGJTCT+bXESHVLTljtucQqvyf/cXZ2yDV WwXonh0rrm0VwgFddJGVO33ylsLbRZBLsRhtMxIfdyaLnfRca0RM42t8V+AguHFkH9NOptNLwhKRm 7TnKZncD9JxMlkXCjfUos60O6jvpPPKSUM6OvYOGV2hR0v1y7d5Kb/eugSPW7cjbfCGDCMxrN3bRp 6AhiDpLixWlYX9aUkEEPqC7uOXcOaVrPrN9SVUgislTNydotmR2vFCBO8nKAZItN2H74jaUGOuL7Y 2h7gRO2PvDT+sw==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 1 Apr 2024 22:25:14 +0200 Message-ID: <0b963eb469dfa61649ca3a75f6745f3ca0a041a9.1712002698.git.ludo@gnu.org> 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: D6CA462ACF X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: -4.55 X-Spam-Score: -4.55 X-TUID: zgvdcGguUnAP * guix/git.scm (repository-info): New procedure. * guix/channels.scm (repository->guix-channel): Use it instead of local code. Change-Id: I74c758c73a22e16031571ca4271cc9cab0492f6e --- guix/channels.scm | 20 ++++++++------------ guix/git.scm | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/guix/channels.scm b/guix/channels.scm index 10f0e3800f..f26ccbc3ae 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -24,6 +24,7 @@ (define-module (guix channels) #:autoload (guix git) (update-cached-checkout url+commit->name commit-difference + repository-info with-repository) #:autoload (guix git-authenticate) (authenticate-repository) #:autoload (guix openpgp) (openpgp-public-key-fingerprint @@ -207,18 +208,13 @@ (define* (repository->guix-channel directory channel that uses that repository and the commit HEAD currently points to; use INTRODUCTION as the channel's introduction. Return #f if no Git repository could be found at DIRECTORY or one of its ancestors." - (catch 'git-error - (lambda () - (with-repository (repository-discover directory) repository - (let* ((head (repository-head repository)) - (commit (oid->string (reference-target head)))) - (channel - (inherit %default-guix-channel) - (url (repository-working-directory repository)) - (commit commit) - (branch (reference-shorthand head)) - (introduction introduction))))) - (const #f))) + (let ((directory commit branch (repository-info directory))) + (channel + (inherit %default-guix-channel) + (url directory) + (commit commit) + (branch branch) + (introduction introduction)))) (define-record-type (channel-instance channel commit checkout) diff --git a/guix/git.scm b/guix/git.scm index cbcdb1904b..760b064a9c 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2020 Mathieu Othacehe -;;; Copyright © 2018-2023 Ludovic Courtès +;;; Copyright © 2018-2024 Ludovic Courtès ;;; Copyright © 2021 Kyle Meyer ;;; Copyright © 2021 Marius Bakke ;;; Copyright © 2022 Maxime Devos @@ -59,6 +59,7 @@ (define-module (guix git) with-repository with-git-error-handling false-if-git-not-found + repository-info update-cached-checkout url+commit->name latest-repository-commit @@ -330,6 +331,22 @@ (define-syntax-rule (with-git-error-handling body ...) (lambda (key err) (report-git-error err)))) +(define (repository-info directory) + "Open the Git repository in DIRECTORY or one of its parent and return three +values: the working directory of that repository, its checked out commit ID, +and its checked out reference (such as a branch name). Return #f (three +values) if DIRECTORY does not hold a readable Git repository." + (catch 'git-error + (lambda () + (with-repository (repository-discover directory) repository + (let* ((head (repository-head repository)) + (commit (oid->string (reference-target head)))) + (values (repository-working-directory repository) + commit + (reference-shorthand head))))) + (lambda _ + (values #f #f #f)))) + (define* (update-submodules repository #:key (log-port (current-error-port)) (fetch-options #f)) -- 2.41.0