aboutsummaryrefslogtreecommitdiff
path: root/guix/channels.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-08-08 17:37:12 +0200
committerLudovic Courtès <ludo@gnu.org>2022-08-09 15:16:06 +0200
commit64a070717c3de32332201df5d6d2d52a7f99dce9 (patch)
tree3cc82ff54e077de279abc7393e9f469c41f79ece /guix/channels.scm
parentcf60a0a906440ccb007bae1243c3e0397c3a0aba (diff)
downloadguix-64a070717c3de32332201df5d6d2d52a7f99dce9.tar
guix-64a070717c3de32332201df5d6d2d52a7f99dce9.tar.gz
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.
Diffstat (limited to 'guix/channels.scm')
-rw-r--r--guix/channels.scm21
1 files changed, 21 insertions, 0 deletions
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-instance channel commit checkout)
channel-instance?