GNU bug report logs - #53060
[PATCH 0/2] Allow the github updater to update git sources

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Maxime Devos <maximedevos@HIDDEN>; Keywords: patch; Done: Ludovic Courtès <ludo@HIDDEN>; Maintainer for guix-patches is guix-patches@HIDDEN.
bug closed, send any further explanations to 53060 <at> debbugs.gnu.org and Maxime Devos <maximedevos@HIDDEN> Request was from Ludovic Courtès <ludo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 53060 <at> debbugs.gnu.org:


Received: (at 53060) by debbugs.gnu.org; 16 Jan 2022 22:20:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 16 17:19:59 2022
Received: from localhost ([127.0.0.1]:44388 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1n9DsV-0002TD-Ls
	for submit <at> debbugs.gnu.org; Sun, 16 Jan 2022 17:19:59 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:56778)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1n9DsS-0002Sv-W2
 for 53060 <at> debbugs.gnu.org; Sun, 16 Jan 2022 17:19:58 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 255E8195;
 Sun, 16 Jan 2022 23:19:50 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id zKMnKh3pdDcK; Sun, 16 Jan 2022 23:19:49 +0100 (CET)
Received: from ribbon (91-160-117-201.subs.proxad.net [91.160.117.201])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 0ADC618A;
 Sun, 16 Jan 2022 23:19:48 +0100 (CET)
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Maxime Devos <maximedevos@HIDDEN>
Subject: Re: bug#53060: [PATCH 0/2] Allow the github updater to update git
 sources
References: <538acb9dc52f6992a5a65846db48f8b7382fb1be.camel@HIDDEN>
Date: Sun, 16 Jan 2022 23:19:48 +0100
In-Reply-To: <538acb9dc52f6992a5a65846db48f8b7382fb1be.camel@HIDDEN>
 (Maxime Devos's message of "Thu, 06 Jan 2022 21:48:15 +0100")
Message-ID: <87wnizz5kr.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spamd-Bar: /
Authentication-Results: hera.aquilenet.fr;
	none
X-Rspamd-Server: hera
X-Rspamd-Queue-Id: 255E8195
X-Spamd-Result: default: False [-0.10 / 15.00]; ARC_NA(0.00)[];
 RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[];
 TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[];
 MIME_GOOD(-0.10)[text/plain];
 DBL_PROHIBIT(0.00)[0.9.0.0:email]; RCPT_COUNT_TWO(0.00)[2];
 FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+];
 RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[];
 MID_RHS_MATCH_FROM(0.00)[]
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 53060
Cc: 53060 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi,

Maxime Devos <maximedevos@HIDDEN> skribis:

> Follow-up to=C2=A0<https://issues.guix.gnu.org/50072>.
>
> To test, you can do
>
> $ make check
> $ ./pre-inst-env guix refresh -t github -u zig
>
> and verify that the version and sha256/base32 has been updated
> (zig@HIDDEN doesn't work though; patches aren't applying cleanly).

Nice, applied!

One comment:

> +(define (call-with-releases thunk tags releases)
> +  (mock ((guix http-client) http-fetch
> +         (lambda* (uri #:key headers)
> +           (unless (string-prefix? "mock://" uri)
> +             (error "the URI ~a should not be used" uri))
> +           (define components
> +             (string-split (substring uri 8) #\/))
> +           (pk 'stuff components headers)
> +           (define (scm->json-port scm)
> +             (open-input-string (scm->json-string scm)))
> +           (match components
> +             (("repos" "foo" "foomatics" "releases")
> +              (scm->json-port releases))
> +             (("repos" "foo" "foomatics" "tags")
> +              (scm->json-port tags))
> +             (rest (error "TODO ~a" rest)))))
> +        (parameterize ((%github-api "mock://"))
> +          (thunk))))

I think the whole point of having the =E2=80=98%github-api=E2=80=99 paramet=
er is that it
allows us to mock the HTTP server instead of having to override bindings
such as =E2=80=98http-fetch=E2=80=99.

I=E2=80=99d have a slight preference for doing that, similar to what is don=
e in
tests/cpan.scm for instance.  WDYT?

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#53060; Package guix-patches. Full text available.

Message received at 53060 <at> debbugs.gnu.org:


Received: (at 53060) by debbugs.gnu.org; 6 Jan 2022 20:50:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 06 15:50:20 2022
Received: from localhost ([127.0.0.1]:42484 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1n5ZiF-0005b5-M4
	for submit <at> debbugs.gnu.org; Thu, 06 Jan 2022 15:50:20 -0500
Received: from michel.telenet-ops.be ([195.130.137.88]:43222)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1n5ZiB-0005aj-2r
 for 53060 <at> debbugs.gnu.org; Thu, 06 Jan 2022 15:50:16 -0500
Received: from localhost.localdomain
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by michel.telenet-ops.be with bizsmtp
 id fYqD260094UW6Th06YqDBW; Thu, 06 Jan 2022 21:50:13 +0100
From: Maxime Devos <maximedevos@HIDDEN>
To: 53060 <at> debbugs.gnu.org
Subject: [PATCH 2/2] import/github: Test it.
Date: Thu,  6 Jan 2022 20:50:12 +0000
Message-Id: <20220106205012.67352-2-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.34.0
In-Reply-To: <20220106205012.67352-1-maximedevos@HIDDEN>
References: <20220106205012.67352-1-maximedevos@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1641502214; bh=Dn8SaHpQ97N/TsbuIfQKi9js25kII1nD80di4Dah7kM=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=F/ySSbwJAITHVI0kCkR/i2ur9B20oiCBgCzsdoXhKxOvC1zKzYGUdUZCSMk7X84S/
 EcCDUUEkAcfUI+dPMK4/RaC3dCBxHmBbG9DmdKgU1moIrQ0f+EieT0/wXrvr6ZaBm4
 3bTCOr0/dMzjbntA9GEU1YNKLg2TjdmiW+LtSWIJD0p+CIbNJQ3nsWLUFwyhFzmOvB
 MHYFHC8wpI8+qhfpbl+Ix3ni/XwtSLAk85S6UGQ+fprxDrKc5Obnd/iuhhTIPI/Ti3
 3hWQdpgn5rPT1NL4hPscCUrnA+FZKkvHBQYKlLmcStl0u2F11mBJt1SUzPuvnIlX0X
 o94v9PtSzzaOA==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53060
Cc: Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

* Makefile.am (SCM_TESTS): Register new tests.
* guix/import/github.scm
  (%github-api): New variable.
  (fetch-releases-or-tags): Use the new variable.
* tests/import-github.scm: New file with tests.
---
 Makefile.am             |   1 +
 guix/import/github.scm  |   9 ++-
 tests/import-github.scm | 139 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+), 3 deletions(-)
 create mode 100644 tests/import-github.scm

diff --git a/Makefile.am b/Makefile.am
index d6aabac261..c10af6155a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -482,6 +482,7 @@ SCM_TESTS =					\
   tests/hackage.scm				\
   tests/home-import.scm				\
   tests/import-git.scm				\
+  tests/import-github.scm			\
   tests/import-utils.scm			\
   tests/inferior.scm				\
   tests/lint.scm				\
diff --git a/guix/import/github.scm b/guix/import/github.scm
index 1adfb8d281..8c1898c0c5 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -39,7 +39,10 @@ (define-module (guix import github)
   #:use-module (guix upstream)
   #:use-module (guix http-client)
   #:use-module (web uri)
-  #:export (%github-updater))
+  #:export (%github-api %github-updater))
+
+;; For tests.
+(define %github-api (make-parameter "https://api.github.com"))
 
 (define (find-extension url)
   "Return the extension of the archive e.g. '.tar.gz' given a URL, or
@@ -150,11 +153,11 @@ (define (fetch-releases-or-tags url)
 'https://api.github.com/repos/aconchillo/guile-json/releases' returns the
 empty list."
   (define release-url
-    (string-append "https://api.github.com/repos/"
+    (string-append (%github-api) "/repos/"
                    (github-user-slash-repository url)
                    "/releases"))
   (define tag-url
-    (string-append "https://api.github.com/repos/"
+    (string-append (%github-api) "/repos/"
                    (github-user-slash-repository url)
                    "/tags"))
 
diff --git a/tests/import-github.scm b/tests/import-github.scm
new file mode 100644
index 0000000000..979a0fc12b
--- /dev/null
+++ b/tests/import-github.scm
@@ -0,0 +1,139 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 Maxime Devos <maximedevos@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-import-github)
+  #:use-module (json)
+  #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-64)
+  #:use-module (guix git-download)
+  #:use-module (guix http-client)
+  #:use-module (guix import github)
+  #:use-module (guix packages)
+  #:use-module (guix tests)
+  #:use-module (guix upstream)
+  #:use-module (ice-9 match))
+
+(test-begin "github")
+
+(define (call-with-releases thunk tags releases)
+  (mock ((guix http-client) http-fetch
+         (lambda* (uri #:key headers)
+           (unless (string-prefix? "mock://" uri)
+             (error "the URI ~a should not be used" uri))
+           (define components
+             (string-split (substring uri 8) #\/))
+           (pk 'stuff components headers)
+           (define (scm->json-port scm)
+             (open-input-string (scm->json-string scm)))
+           (match components
+             (("repos" "foo" "foomatics" "releases")
+              (scm->json-port releases))
+             (("repos" "foo" "foomatics" "tags")
+              (scm->json-port tags))
+             (rest (error "TODO ~a" rest)))))
+        (parameterize ((%github-api "mock://"))
+          (thunk))))
+
+;; Copied from tests/minetest.scm
+(define (upstream-source->sexp upstream-source)
+  (define url (upstream-source-urls upstream-source))
+  (unless (git-reference? url)
+    (error "a <git-reference> is expected"))
+  `(,(upstream-source-package upstream-source)
+    ,(upstream-source-version upstream-source)
+    ,(git-reference-url url)
+    ,(git-reference-commit url)))
+
+(define* (expected-sexp new-version new-commit)
+  `("foomatics" ,new-version "https://github.com/foo/foomatics" ,new-commit))
+
+(define (example-package old-version old-commit)
+  (package
+    (name "foomatics")
+    (version old-version)
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/foo/foomatics")
+             (commit old-commit)))
+       (sha256 #f) ; not important for following tests
+       (file-name (git-file-name name version))))
+    (build-system #f)
+    (license #f)
+    (synopsis #f)
+    (description #f)
+    (home-page #f)))
+
+(define* (found-sexp old-version old-commit tags releases)
+  (and=>
+   (call-with-releases (lambda ()
+                         ((upstream-updater-latest %github-updater)
+                          (example-package old-version old-commit)))
+                       tags releases)
+   upstream-source->sexp))
+
+(define-syntax-rule (test-release test-case old-version
+                                  old-commit new-version new-commit
+                                  tags releases)
+  (test-equal test-case
+    (expected-sexp new-version new-commit)
+    (found-sexp old-version old-commit tags releases)))
+
+(test-release "newest release is choosen"
+  "1.0.0" "v1.0.0" "1.9" "v1.9"
+  #()
+  ;; a mixture of current, older and newer versions
+  #((("tag_name" . "v0.0"))
+    (("tag_name" . "v1.0.1"))
+    (("tag_name" . "v1.9"))
+    (("tag_name" . "v1.0.0"))
+    (("tag_name" . "v1.0.2"))))
+
+(test-release "tags are used when there are no formal releases"
+  "1.0.0" "v1.0.0" "1.9" "v1.9"
+  ;; a mixture of current, older and newer versions
+  #((("name" . "v0.0"))
+    (("name" . "v1.0.1"))
+    (("name" . "v1.9"))
+    (("name" . "v1.0.0"))
+    (("name" . "v1.0.2")))
+  #())
+
+(test-release "\"version-\" prefixes are recognised"
+  "1.0.0" "v1.0.0" "1.9" "version-1.9"
+  #((("name" . "version-1.9")))
+  #())
+
+(test-release "prefixes are optional"
+  "1.0.0" "v1.0.0" "1.9" "1.9"
+  #((("name" . "1.9")))
+  #())
+
+(test-release "prefixing by package name is acceptable"
+  "1.0.0" "v1.0.0" "1.9" "foomatics-1.9"
+  #((("name" . "foomatics-1.9")))
+  #())
+
+(test-release "not all prefixes are acceptable"
+  "1.0.0" "v1.0.0" "1.0.0" "v1.0.0"
+  #((("name" . "v1.0.0"))
+    (("name" . "barstatics-1.9")))
+  #())
+
+(test-end "github")
-- 
2.34.0





Information forwarded to guix-patches@HIDDEN:
bug#53060; Package guix-patches. Full text available.

Message received at 53060 <at> debbugs.gnu.org:


Received: (at 53060) by debbugs.gnu.org; 6 Jan 2022 20:50:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 06 15:50:16 2022
Received: from localhost ([127.0.0.1]:42482 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1n5ZiC-0005av-8H
	for submit <at> debbugs.gnu.org; Thu, 06 Jan 2022 15:50:16 -0500
Received: from michel.telenet-ops.be ([195.130.137.88]:43218)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1n5ZiB-0005ah-2i
 for 53060 <at> debbugs.gnu.org; Thu, 06 Jan 2022 15:50:15 -0500
Received: from localhost.localdomain
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by michel.telenet-ops.be with bizsmtp
 id fYqD260094UW6Th06YqDBT; Thu, 06 Jan 2022 21:50:13 +0100
From: Maxime Devos <maximedevos@HIDDEN>
To: 53060 <at> debbugs.gnu.org
Subject: [PATCH 1/2] import/github: Return <git-reference> objects for
 git-fetch origins.
Date: Thu,  6 Jan 2022 20:50:11 +0000
Message-Id: <20220106205012.67352-1-maximedevos@HIDDEN>
X-Mailer: git-send-email 2.34.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1641502213; bh=dYJu5z7gAB6SomKy1Tq8oIwY6UsejtiveeCsbVZ4gy4=;
 h=From:To:Cc:Subject:Date;
 b=TTi7gE+aWyaOBkWIoIWbd2XVaRzvNMoHqhc7+fOfq2MRhFG93iViDBL4OMSbth3bJ
 CvnSJEwHMpYmewpxxy2Dn6HpbPQWY3uKYvMjwxpkAPdH6tUxEEVu3NGlHg3pldIqRj
 FTrgujy1LECElJRrvRFY57TaGNvUvp9bk7srUZicxGMvRKTib0/9UW7rWhUBUxndKe
 Q7XGf5KlxGMTxkT9BMDXlzUZWZzUpY0CWZFW/o9f/EKh5AsFtRbOjldOPA9CzX6iE9
 +B2wBRm8tA1yHm+a1i2FFZiEkuAkNFQUm2j16a33SIjgySA3OtbyvWUYLdzxmnxGVV
 b0opNPhyMNgsg==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 53060
Cc: Maxime Devos <maximedevos@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

* guix/import/github.scm
  (latest-released-version): Also return the tag.
  (latest-release): Use this information to return <git-reference> objects
  when appropriate.
---
 guix/import/github.scm | 43 ++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/guix/import/github.scm b/guix/import/github.scm
index 888b148ffb..1adfb8d281 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2018 Eric Bavier <bavier@HIDDEN>
 ;;; Copyright © 2019 Arun Isaac <arunisaac@HIDDEN>
 ;;; Copyright © 2019 Efraim Flashner <efraim@HIDDEN>
+;;; Copyright © 2022 Maxime Devos <maximedevos@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -25,6 +26,7 @@ (define-module (guix import github)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-71)
   #:use-module (guix utils)
   #:use-module (guix i18n)
   #:use-module (guix diagnostics)
@@ -181,12 +183,15 @@ (define headers
         (x x)))))
 
 (define (latest-released-version url package-name)
-  "Return a string of the newest released version name given a string URL like
+  "Return the newest released version and its tag given a string URL like
 'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz' and the name of
-the package e.g. 'bedtools2'.  Return #f if there is no releases"
+the package e.g. 'bedtools2'.  Return #f (two values) if there are no
+releases."
   (define (pre-release? x)
     (assoc-ref x "prerelease"))
 
+  ;; This procedure returns (version . tag) pair, or #f
+  ;; if RELEASE doesn't seyem to correspond to a version.
   (define (release->version release)
     (let ((tag (or (assoc-ref release "tag_name") ;a "release"
                    (assoc-ref release "name")))   ;a tag
@@ -197,22 +202,22 @@ (define (release->version release)
        ((and (< name-length (string-length tag))
              (string=? (string-append package-name "-")
                        (substring tag 0 (+ name-length 1))))
-        (substring tag (+ name-length 1)))
+        (cons (substring tag (+ name-length 1)) tag))
        ;; some tags start with a "v" e.g. "v0.25.0"
        ;; or with the word "version" e.g. "version.2.1"
        ;; where some are just the version number
        ((string-prefix? "version" tag)
-        (if (char-set-contains? char-set:digit (string-ref tag 7))
-            (substring tag 7)
-            (substring tag 8)))
+        (cons (if (char-set-contains? char-set:digit (string-ref tag 7))
+                  (substring tag 7)
+                  (substring tag 8)) tag))
        ((string-prefix? "v" tag)
-        (substring tag 1))
+        (cons (substring tag 1) tag))
        ;; Finally, reject tags that don't start with a digit:
        ;; they may not represent a release.
        ((and (not (string-null? tag))
              (char-set-contains? char-set:digit
                                  (string-ref tag 0)))
-        tag)
+        (cons tag tag))
        (else #f))))
 
   (let* ((json (and=> (fetch-releases-or-tags url)
@@ -229,14 +234,14 @@ (define (release->version release)
                                  (match (remove pre-release? json)
                                    (() json) ; keep everything
                                    (releases releases)))
-                     version>?)
-          ((latest-release . _) latest-release)
-          (() #f)))))
+                     (lambda (x y) (version>? (car x) (car y))))
+          (((latest-version . tag) . _) (values latest-version tag))
+          (() (values #f #f))))))
 
 (define (latest-release pkg)
   "Return an <upstream-source> for the latest release of PKG."
-  (define (origin-github-uri origin)
-    (match (origin-uri origin)
+  (define (github-uri uri)
+    (match uri
       ((? string? url)
        url)                                       ;surely a github.com URL
       ((? download:git-reference? ref)
@@ -244,14 +249,20 @@ (define (origin-github-uri origin)
       ((urls ...)
        (find (cut string-contains <> "github.com") urls))))
 
-  (let* ((source-uri (origin-github-uri (package-source pkg)))
+  (let* ((original-uri (origin-uri (package-source pkg)))
+         (source-uri (github-uri original-uri))
          (name (package-name pkg))
-         (newest-version (latest-released-version source-uri name)))
+         (newest-version version-tag
+                         (latest-released-version source-uri name)))
     (if newest-version
         (upstream-source
          (package name)
          (version newest-version)
-         (urls (list (updated-github-url pkg newest-version))))
+         (urls (if (download:git-reference? original-uri)
+                   (download:git-reference
+                    (inherit original-uri)
+                    (commit version-tag))
+                   (list (updated-github-url pkg newest-version)))))
         #f))) ; On GitHub but no proper releases
 
 (define %github-updater

base-commit: 90bc18bcd4d221b53e52f94039d256d2a8edea5b
prerequisite-patch-id: 2888bb74d524c7eee9edef94c8f06f099291e7d9
prerequisite-patch-id: 24d16d7354ddca4822f631a883c8e8789c818533
prerequisite-patch-id: ab72bad504c2df472d539b6a8205fed9c89416ab
prerequisite-patch-id: 8c91ca86901e3f61d1363d521fa825ac680f60d8
-- 
2.34.0





Information forwarded to guix-patches@HIDDEN:
bug#53060; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 6 Jan 2022 20:48:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 06 15:48:35 2022
Received: from localhost ([127.0.0.1]:42474 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1n5ZgT-0005XY-Ks
	for submit <at> debbugs.gnu.org; Thu, 06 Jan 2022 15:48:35 -0500
Received: from lists.gnu.org ([209.51.188.17]:36092)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <maximedevos@HIDDEN>) id 1n5ZgS-0005XQ-2X
 for submit <at> debbugs.gnu.org; Thu, 06 Jan 2022 15:48:28 -0500
Received: from eggs.gnu.org ([209.51.188.92]:33884)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <maximedevos@HIDDEN>)
 id 1n5ZgR-0006Zi-Df
 for guix-patches@HIDDEN; Thu, 06 Jan 2022 15:48:27 -0500
Received: from [2a02:1800:110:4::f00:18] (port=40416
 helo=michel.telenet-ops.be)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <maximedevos@HIDDEN>)
 id 1n5ZgO-0000XM-Ts
 for guix-patches@HIDDEN; Thu, 06 Jan 2022 15:48:26 -0500
Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be
 ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a])
 by michel.telenet-ops.be with bizsmtp
 id fYoL260034UW6Th06YoL2Q; Thu, 06 Jan 2022 21:48:20 +0100
Message-ID: <538acb9dc52f6992a5a65846db48f8b7382fb1be.camel@HIDDEN>
Subject: [PATCH 0/2] Allow the github updater to update git sources
From: Maxime Devos <maximedevos@HIDDEN>
To: guix-patches@HIDDEN
Date: Thu, 06 Jan 2022 21:48:15 +0100
Content-Type: multipart/signed; micalg="pgp-sha512";
 protocol="application/pgp-signature"; boundary="=-Fzx4kT+PzLAft4L0SzRy"
User-Agent: Evolution 3.38.3-1 
MIME-Version: 1.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r22;
 t=1641502100; bh=8Bg6/J5k4iKiTbRFoEdqjZnVEGjn5t7QwmlHnX2r4LY=;
 h=Subject:From:To:Date;
 b=dthgkPwNmDxhTm3UUi/QWotTpq1pKQUQ1tILcVCYJ5qZ1U0yBU2oesJ+zd6Xm+q1j
 8LOhNlNvqlOB4DoOGMtUFdDQZ1XAOwZKHAoNjp8Gk566W/z3kyg7l1o4GRZ6JxFbxJ
 DOYBwgKQvObAeUVrnRNdlXYR9Lg3+YUZjP8VynTz/dtbtbjuTvx3wR90Q6r7kqmwCO
 nsgU3SNWkvp5LY/PGkqbSrYQEdxo15F0TvteO/jwO8Ez0ekyTkkyxQZNzL7n7jf4z8
 7nZJX4wvqbMMBE9Uh9/v2CTzCo1jPt3/dFI5DSayBQ39lFLHwG023rysrQETP1lPCn
 EBJHjrF4au1Hg==
X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a02:1800:110:4::f00:18
 (failed)
Received-SPF: pass client-ip=2a02:1800:110:4::f00:18;
 envelope-from=maximedevos@HIDDEN; helo=michel.telenet-ops.be
X-Spam_score_int: -19
X-Spam_score: -2.0
X-Spam_bar: --
X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_LOW=-0.7, RDNS_NONE=0.793, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.1 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


--=-Fzx4kT+PzLAft4L0SzRy
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Follow-up to=C2=A0<https://issues.guix.gnu.org/50072>.

To test, you can do

$ make check
$ ./pre-inst-env guix refresh -t github -u zig

and verify that the version and sha256/base32 has been updated
(zig@HIDDEN doesn't work though; patches aren't applying cleanly).

Greetings,
Maxime.

--=-Fzx4kT+PzLAft4L0SzRy
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYddVjxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7kdbAP9cUen8BQDlmDha8T6+mwJc9Wqw
RobZmKxbCSx66+OZCAD/buXq/hA+Wp7zFDnyPxUWJze2Ao032BA2o41y3RNMwAU=
=OByh
-----END PGP SIGNATURE-----

--=-Fzx4kT+PzLAft4L0SzRy--





Acknowledgement sent to Maxime Devos <maximedevos@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#53060; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 16 Jan 2022 22:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.