From 64a070717c3de32332201df5d6d2d52a7f99dce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 8 Aug 2022 17:37:12 +0200 Subject: channels: Add 'repository->guix-channel'. * guix/channels.scm (repository->guix-channel): New procedure. * guix/scripts/describe.scm (display-checkout-info): Use it instead of the (git) interface, and adjust accordingly. --- guix/channels.scm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'guix/channels.scm') diff --git a/guix/channels.scm b/guix/channels.scm index 689b30e0eb..a5e9d7774d 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -77,6 +77,7 @@ %default-guix-channel %default-channels guix-channel? + repository->guix-channel channel-instance? channel-instance-channel @@ -202,6 +203,26 @@ introduction, add it." (introduction %guix-channel-introduction)) chan)) +(define* (repository->guix-channel directory + #:key + (introduction %guix-channel-introduction)) + "Look for a Git repository in DIRECTORY or its ancestors and return a +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))) + (define-record-type (channel-instance channel commit checkout) channel-instance? -- cgit v1.2.3