all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Xinglu Chen <public@yoctocell.xyz>
To: 47670@debbugs.gnu.org
Subject: [bug#47670] [PATCH 1/2] upstream: Add predicate for Git URLs.
Date: Fri, 09 Apr 2021 11:05:03 +0200	[thread overview]
Message-ID: <834e423bf8682e98d55bddb8f7c9b50389f7326c.1617958554.git.public@yoctocell.xyz> (raw)
In-Reply-To: <cover.1617958554.git.public@yoctocell.xyz>

* guix/upstream.scm (git-url-predicate): New procedure.
---
 guix/upstream.scm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/guix/upstream.scm b/guix/upstream.scm
index 632e9ebc4f..47d11043dd 100644
--- a/guix/upstream.scm
+++ b/guix/upstream.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,6 +25,7 @@
   #:use-module (guix discovery)
   #:use-module ((guix download)
                 #:select (download-to-store url-fetch))
+  #:use-module (guix git-download)
   #:use-module (guix gnupg)
   #:use-module (guix packages)
   #:use-module (guix diagnostics)
@@ -54,6 +56,7 @@
 
             url-predicate
             url-prefix-predicate
+            git-url-predicate
             coalesce-sources
 
             upstream-updater
@@ -185,6 +188,23 @@ MATCHING-URL?."
 source URLs starts with PREFIX."
   (url-predicate (cut string-prefix? prefix <>)))
 
+(define (git-url-predicate matching-url?)
+  "Return a predicate that returns true when passed a package whose source is
+an <origin> with the GIT-FETCH method, and one of its URLs passes
+MATCHING-URL?."
+  (lambda (package)
+    (match (package-source package)
+      ((? origin? origin)
+       (and (eq? (origin-method origin) git-fetch)
+            (match (origin-uri origin)
+              ((? git-reference? git-reference)
+               (matching-url? (git-reference-url git-reference)))
+              (((? git-reference? git-reference) ...)
+               (any matching-url? (git-reference-url git-reference)))
+              (_
+               #f))))
+      (_ #f))))
+
 (define (upstream-source-archive-types release)
   "Return the available types of archives for RELEASE---a list of strings such
 as \"gz\" or \"xz\"."
-- 
2.31.1






  reply	other threads:[~2021-04-09  9:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09  9:02 [bug#47670] [PATCH 0/2] Add updater for packages hosted as SourceHut Git repositories Xinglu Chen
2021-04-09  9:05 ` Xinglu Chen [this message]
2021-04-09  9:05 ` [bug#47670] [PATCH 2/2] gnu-maintenance: Add 'sourcehut-git' updater Xinglu Chen
2021-04-09 10:54 ` [bug#47670] [PATCH 0/2] Add updater for packages hosted as SourceHut Git repositories Léo Le Bouter via Guix-patches via
2021-04-09 11:58   ` Xinglu Chen
2021-04-09 12:04     ` Léo Le Bouter via Guix-patches via
2021-04-09 12:41       ` Xinglu Chen
2021-04-09 12:48         ` Xinglu Chen
2021-06-06 13:23           ` Ludovic Courtès
2021-06-11  9:25             ` Xinglu Chen
2021-07-27 10:19               ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=834e423bf8682e98d55bddb8f7c9b50389f7326c.1617958554.git.public@yoctocell.xyz \
    --to=public@yoctocell.xyz \
    --cc=47670@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.