From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wCa3JdWHNWGr0wAAgWs5BA (envelope-from ) for ; Mon, 06 Sep 2021 05:15:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GEdmIdWHNWHdAwAAB5/wlQ (envelope-from ) for ; Mon, 06 Sep 2021 03:15:33 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 06BA8B273 for ; Mon, 6 Sep 2021 05:15:33 +0200 (CEST) Received: from localhost ([::1]:41780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mN56a-0001XS-1L for larch@yhetil.org; Sun, 05 Sep 2021 23:15:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mN566-0001TX-6m for guix-patches@gnu.org; Sun, 05 Sep 2021 23:15:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mN565-00041D-S3 for guix-patches@gnu.org; Sun, 05 Sep 2021 23:15:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mN565-0000Wc-MN for guix-patches@gnu.org; Sun, 05 Sep 2021 23:15:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50359] [PATCH] import: Add 'generic-git' updater. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 06 Sep 2021 03:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50359 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Xinglu Chen Cc: 50359@debbugs.gnu.org Received: via spool by 50359-submit@debbugs.gnu.org id=B50359.16308980961992 (code B ref 50359); Mon, 06 Sep 2021 03:15:01 +0000 Received: (at 50359) by debbugs.gnu.org; 6 Sep 2021 03:14:56 +0000 Received: from localhost ([127.0.0.1]:51288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mN560-0000W4-IS for submit@debbugs.gnu.org; Sun, 05 Sep 2021 23:14:56 -0400 Received: from out2.migadu.com ([188.165.223.204]:13490) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mN55x-0000Vt-3z for 50359@debbugs.gnu.org; Sun, 05 Sep 2021 23:14:54 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1630898091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xUrn6lZE3xVKauxh73rs8SYlgQuSTAK1Bn2VQe/8pXk=; b=LvTReMGbQawATevtl9is1eatz2cFz9S72jIAZrnTo53GLiKakkU00gpLyCCgfiF4ZzztXB V3tj8yyF1RJAOgbsflLR1wmTAlP+VnIqwreOMyWAM4vW/4BuVDdIwcUxvIm2DT7cJpw1xx GuIJNX8nVJ7ReXZiYL5EO3R8kjVd72o= From: Sarah Morgensen References: <86k0jvkh5v.fsf@mgsn.dev> <87eea3416x.fsf@yoctocell.xyz> Date: Sun, 05 Sep 2021 20:14:49 -0700 In-Reply-To: <87eea3416x.fsf@yoctocell.xyz> (Xinglu Chen's message of "Sun, 05 Sep 2021 15:11:18 +0200 (5 hours, 24 minutes, 26 seconds ago)") Message-ID: <861r62jsye.fsf@mgsn.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Auth-User: iskarian@mgsn.dev X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630898133; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=xUrn6lZE3xVKauxh73rs8SYlgQuSTAK1Bn2VQe/8pXk=; b=oBH8czfFk3aYEJCYZPOw0pw9KSWZqCACiS1Cy9YfmjNzcLVDUxom91yh/tM+l6+YCaXl33 /HJ9T+8DcYNUBN0903f43MZNK4q+cEXbPAYKiVtFqVJQvTrkXpL3cjrODbUsUp58ut2NrM osRAKaVuAuYXKfSfTZQVgWFi5ARQhLn1FEC59GxlhNZGe/mwUDLFNmSDPj/FOt/i730yW9 rynv94pgT8fghjgH//GqUiQPR5RFAFlO+KkirQ0DFbPRxLTEPQXHuFgjVNacmUC+7kku4S 5Dc7geHUDxzGntxz06VHKMP1OZn88pKl0i6LhXYxko8vV1QsKBwQSCmkzLVXIg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630898133; a=rsa-sha256; cv=none; b=XAetkdun+LJntoT3rpl2xgq4ykGSInk9JTulb3wZroF5G1mz/ixscVPG6w78xowzJBs7Ph fUvUMJnmBxwqxl/1KiSa8ufu9vRRNgpY08wA+UZpgEj/FR9j2p5h+naeyfjo1MkYkS2qZB nEBkdqiMaBbmgdk8hIOPhUZzdyybJkbLkjpEOQXm3hbcNfAF9zirDEXtcT002Xy5qh3fGM h/OckWe87Sm/D3nVSGEMuh0DgVJtnFxKfz9YV5kmKA557SoOvEcsAC0AmZYVDWePBIxPNd JCpfAI1V+nTYjL+YYCTnEVeqh7I2uPIt3XRreLipVEesYeiC82emwg0meBMUvQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=LvTReMGb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.31 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=LvTReMGb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 06BA8B273 X-Spam-Score: -1.31 X-Migadu-Scanner: scn1.migadu.com X-TUID: ppztsx4VB9sW Hello, Xinglu Chen writes: >> And this lets us just do something like (untested): >> >> (define* (get-version tag #:key prefix suffix delim) >> (define delim-rx (regexp-quote (or delim "."))) >> (define prefix-rx (or prefix "[^[:digit:]]*")) >> (define suffix-rx (or suffix ".*")) >> (define version-char-rx >> (string-append "[^" delim-rx "[:punct:]]")) >> >> (define tag-rx >> (string-append "^" prefix "(" version-char-rx "+(" >> delim-rx version-char-rx ")*)" suffix-rx "$")) > > This wouldn=E2=80=99t match anything if the version is just a plain numbe= r, > e.g., 1 or 09. It does, but I had many errors in the definition. Again, apologies. I shouldn't send emails that late, haha. This method should read: --8<---------------cut here---------------start------------->8--- (define* (get-version tag #:key prefix suffix delim) (define delim-rx (regexp-quote (or delim "."))) (define prefix-rx (or prefix "[^[:digit:]]*")) (define suffix-rx (or suffix ".*")) (define version-char-rx (string-append "[^" delim-rx "[:punct:]]")) (define tag-rx (string-append "^" prefix-rx "(" version-char-rx "+(" delim-rx version-char-rx "+)*)" suffix-rx "$")) (and=3D> (string-match tag-rx tag) (cut match:substring <> 1))) --8<---------------cut here---------------end--------------->8--- > > With this, something like =E2=80=9C1.4.0rc1-450-g2725ef99d=E2=80=9D will = result in > =E2=80=9C1.4.0=E2=80=9D being returned, which is incorrect. Changing (cut > match:substring <> 1) to just =E2=80=98match:substring=E2=80=99 would sol= ve the issue, > but then pre-release tags, which we usually don=E2=80=99t want, would al= so get > matched. Not sure what the best option would be in this case. > With the fixed method above: scheme@(emacs-guix)> (get-version "8") $16 =3D "8" scheme@(emacs-guix)> (get-version "1.4.0rc1-450-g2725ef99d") $17 =3D "1.4.0rc1" But, we still get: scheme@(emacs-guix)> (get-version "1.4.0-rc1") $18 =3D "1.4.0" which leads us to what you talked about in your other message. [...] >> +(define* (ls-remote-refs url #:key tags?) >> + "Return the list of references advertised at Git repository URL. If = TAGS? >> +is true, limit to only refs/tags." >> + (define (ref? ref) >> + ;; Like `git ls-remote --refs', only show actual references. >> + (and (string-prefix? "refs/" ref) >> + (not (string-suffix? "^{}" ref)))) >> + >> + (define (tag? ref) >> + (string-prefix? "refs/tags/" ref)) >> + >> + (define (include? ref) >> + (and ref? This should be: (and (ref? ref) >> + (or (not tags?) (tag? ref)))) >> + >> + (with-libgit2 >> + (with-temporary-directory >> + (lambda (cache-directory) >> + (let* ((repository (repository-init cache-directory)) >> + ;; Create an in-memory remote so we don't touch disk. >> + (remote (remote-create-anonymous repository url))) >> + (remote-connect remote) >> + (remote-disconnect remote) >> + (repository-close! repository) >> + >> + (filter include? (map remote-head-name (remote-ls remote)))))))) >> > > For some reason it seems to include refs that do and don=E2=80=99t end wi= th > =E2=80=9C^{}=E2=80=9D Sorry, another typo I missed. See above. -- Sarah