all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hartmut Goebel <h.goebel@crazy-compilers.com>
To: 57460@debbugs.gnu.org
Subject: [bug#57460] [PATCH v3 09/18] import: git: Allow updating to a specific version.
Date: Tue, 20 Dec 2022 10:34:14 +0100	[thread overview]
Message-ID: <db29d7a6f37dfc4130a3e18639bb1a4fe2bf5db0.1671527962.git.h.goebel@crazy-compilers.com> (raw)
In-Reply-To: <cover.1671527962.git.h.goebel@crazy-compilers.com>

* guix/import/git.scm
  (latest-tag): Add #:version argument. If version is given, try to
  find the respective version tag.
  (latest-git-tag-version): Add #:version argument and pass it on to
  called functions.
  (latest-releease) Rename to 'import-release', add #:version argument
  and pass it on to called functions.
---
 guix/import/git.scm | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/guix/import/git.scm b/guix/import/git.scm
index bb5ba4d97e..c15943bd7c 100644
--- a/guix/import/git.scm
+++ b/guix/import/git.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -146,9 +147,11 @@ version corresponding to the tag, and the cdr is the name of the tag."
                            tags)
                entry<?))
 
-(define* (latest-tag url #:key prefix suffix delim pre-releases?)
+(define* (latest-tag url
+                     #:key prefix suffix delim pre-releases? (version #f))
   "Return the latest version and corresponding tag available from the Git
-repository at URL."
+repository at URL. Optionally include a VERSION string to fetch a specific
+version."
   (define (pre-release? tag)
     (any (cut regexp-exec <> tag)
          %pre-release-rx))
@@ -169,13 +172,22 @@ repository at URL."
      ((null? versions->tags)
       (git-no-valid-tags-error))
      (else
-      (match (last versions->tags)
-        ((version . tag)
-         (values version tag)))))))
-
-(define (latest-git-tag-version package)
+      (let ((versions (if version
+                          (filter (match-lambda
+                                   ((candidate-version . tag)
+                                    (string=? version candidate-version)))
+                                  versions->tags)
+                          versions->tags)))
+        (if (null? versions)
+            (values #f #f)
+            (match (last versions)
+              ((version . tag)
+               (values version tag)))))))))
+
+(define* (latest-git-tag-version package #:key (version #f))
   "Given a PACKAGE, return the latest version of it and the corresponding git
-tag, or #false and #false if the latest version could not be determined."
+tag, or #false and #false if the latest version could not be determined.
+Optionally include a VERSION string to fetch a specific version."
   (guard (c ((or (git-no-tags-error? c) (git-no-valid-tags-error? c))
              (warning (or (package-field-location package 'source)
                           (package-location package))
@@ -193,6 +205,7 @@ tag, or #false and #false if the latest version could not be determined."
            (url (git-reference-url (origin-uri source)))
            (property (cute assq-ref (package-properties package) <>)))
       (latest-tag url
+                  #:version version
                   #:prefix (property 'release-tag-prefix)
                   #:suffix (property 'release-tag-suffix)
                   #:delim (property 'release-tag-version-delimiter)
@@ -206,12 +219,14 @@ tag, or #false and #false if the latest version could not be determined."
           (git-reference? (origin-uri origin))))
     (_ #f)))
 
-(define (latest-git-release package)
-  "Return an <upstream-source> for the latest release of PACKAGE."
+(define* (import-git-release package #:key (version #f))
+  "Return an <upstream-source> for the latest release of PACKAGE.
+Optionally include a VERSION string to fetch a specific version."
   (let* ((name (package-name package))
          (old-version (package-version package))
          (old-reference (origin-uri (package-source package)))
-         (new-version new-version-tag (latest-git-tag-version package)))
+         (new-version new-version-tag
+                      (latest-git-tag-version package #:version version)))
     (and new-version new-version-tag
          (upstream-source
           (package name)
@@ -226,4 +241,4 @@ tag, or #false and #false if the latest version could not be determined."
    (name 'generic-git)
    (description "Updater for packages hosted on Git repositories")
    (pred git-package?)
-   (import latest-git-release)))
+   (import import-git-release)))
-- 
2.30.6





  parent reply	other threads:[~2022-12-20  9:38 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-28 13:15 [bug#57460] [PATCH 00/19] Refresh to specific version Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 01/20] upstream-updater: Rename record field Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 02/20] import: cpan: Remove unused exports Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 03/20] updaters: Issue error-message if version is given: Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 04/20] import: sourceforge: Issue error-message if version is given Hartmut Goebel
2022-08-28 13:22   ` Maxime Devos
2022-08-28 13:18 ` [bug#57460] [PATCH 05/20] refresh: Allow updating to a specific version (gnu-maintenance) Hartmut Goebel
2022-09-24  9:17   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 06/20] refresh: Allow updating to a specific version (crate) Hartmut Goebel
2022-09-24  9:19   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 07/20] refresh: Allow updating to a specific version (egg) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 08/20] refresh: Allow updating to a specific version (git) Hartmut Goebel
2022-09-24  9:24   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 09/20] refresh: Allow updating to a specific version (github) Hartmut Goebel
2022-09-24  9:26   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 10/20] refresh: Allow updating to a specific version (gnome) Hartmut Goebel
2022-09-24  9:29   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-09-24 10:25     ` Maxime Devos
2022-09-24 16:31       ` Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 11/20] refresh: Allow updating to a specific version (hexpm) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 12/20] refresh: Allow updating to a specific version (kde) Hartmut Goebel
2022-09-24  9:34   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 13/20] refresh: Allow updating to a specific version (launchpad) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 14/20] refresh: Allow updating to a specific version (pypi) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 15/20] refresh: Allow updating to a specific version (script) Hartmut Goebel
2022-08-28 13:26   ` Maxime Devos
2022-09-24  9:45   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-11-01 15:58     ` Hartmut Goebel
2022-11-22  7:33       ` Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 16/20] refresh: Allow updating to a specific version (upstream) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 17/20] refresh: Allow updating to a specific version (documentation) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 18/20] TEMP REMOVE import: git: Restrict to non-github origins Hartmut Goebel
2022-08-28 17:26   ` Liliana Marie Prikler
2022-08-28 13:18 ` [bug#57460] [PATCH 19/20] TEMP REMOVE upstream: Output names of importers tried Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 20/20] TEMP REMOVE Add test-script for refesh-with-version Hartmut Goebel
2022-08-28 13:30 ` [bug#57460] [PATCH 00/19] Refresh to specific version Maxime Devos
2022-09-24  9:48   ` Ludovic Courtès
2022-11-01 16:02     ` Hartmut Goebel
2022-12-20  9:34 ` [bug#57460] [PATCH v3 00/18] " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 01/18] upstream-updater: Rename record field Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 02/18] import: cpan: Remove unused exports Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 03/18] import: Issue error-message if version is given Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 04/18] import: sourceforge: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 05/18] gnu-maintenance: Allow updating to a specific version Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 06/18] import: crate: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 07/18] import: egg: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 08/18] import: gem: " Hartmut Goebel
2022-12-20  9:34   ` Hartmut Goebel [this message]
2022-12-20  9:34   ` [bug#57460] [PATCH v3 10/18] import: github: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 11/18] import: gnome: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 12/18] import: hexpm: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 13/18] import: kde: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 14/18] import: launchpad: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 15/18] import: pypi: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 16/18] refresh: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 17/18] upstream: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 18/18] doc: Describe how to update " Hartmut Goebel
2022-12-23 22:42     ` [bug#57460] [PATCH 00/19] Refresh to " Ludovic Courtès
2022-12-23 22:45   ` Ludovic Courtès
2022-12-26 16:42     ` bug#57460: " Hartmut Goebel

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=db29d7a6f37dfc4130a3e18639bb1a4fe2bf5db0.1671527962.git.h.goebel@crazy-compilers.com \
    --to=h.goebel@crazy-compilers.com \
    --cc=57460@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.