guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#48999] [PATCH v2 2/3] import: utils: Add predicates for checking VC


From: Xinglu Chen
Subject: [bug#48999] [PATCH v2 2/3] import: utils: Add predicates for checking VCS repositories.
Date: Sun, 04 Jul 2021 13:54:18 +0200

* guix/import/utils.scm (git-repository?, hg-repository?): New procedures.
---
 guix/import/utils.scm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index d817318a91..bcf26ae363 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com>
 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -43,6 +44,7 @@
   #:use-module (ice-9 rdelim)
   #:use-module (ice-9 receive)
   #:use-module (ice-9 regex)
+  #:use-module (ice-9 ftw)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-11)
@@ -74,6 +76,9 @@
 
             guix-name
 
+            git-repository?
+            hg-repository?
+            
             recursive-import))
 
 (define (factorize-uri uri version)
@@ -422,6 +427,16 @@ separated by PRED."
                                       (chr (char-downcase chr)))
                                     name)))
 
+(define (git-repository? directory)
+  "Check whether DIRECTORY is a Git repository."
+  (let ((contents (scandir directory)))
+    (if (member ".git" contents) #t #f)))
+
+(define (hg-repository? directory)
+  "Check whether DIRECTORY is a Hg repository."
+  (let ((contents (scandir directory)))
+    (if (member ".hg" contents) #t #f)))
+
 (define (topological-sort nodes
                           node-dependencies
                           node-name)
-- 
2.32.0







reply via email to

[Prev in Thread] Current Thread [Next in Thread]