From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CCOLOhLyNWGVDwAAgWs5BA (envelope-from ) for ; Mon, 06 Sep 2021 12:48:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id aOWANhLyNWE2OAAAB5/wlQ (envelope-from ) for ; Mon, 06 Sep 2021 10:48:50 +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 7E999B2C2 for ; Mon, 6 Sep 2021 12:48:50 +0200 (CEST) Received: from localhost ([::1]:51604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNCBF-0002Yl-Ip for larch@yhetil.org; Mon, 06 Sep 2021 06:48:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNC2k-0002W5-94 for guix-patches@gnu.org; Mon, 06 Sep 2021 06:40:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNC2k-0002jS-0q for guix-patches@gnu.org; Mon, 06 Sep 2021 06:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mNC2j-0002o0-UU for guix-patches@gnu.org; Mon, 06 Sep 2021 06:40:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50377] [PATCH v3 2/2] transformations: 'git describe' style commit IDs are used as version. Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 06 Sep 2021 10:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50377 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50377@debbugs.gnu.org Received: via spool by 50377-submit@debbugs.gnu.org id=B50377.163092474610676 (code B ref 50377); Mon, 06 Sep 2021 10:40:01 +0000 Received: (at 50377) by debbugs.gnu.org; 6 Sep 2021 10:39:06 +0000 Received: from localhost ([127.0.0.1]:52062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1p-0002m7-NG for submit@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1n-0002l9-Sn for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35078) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNC1i-0001qW-MH for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:58 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38044 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNC1g-0000IT-IR for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:58 -0400 From: Marius Bakke Date: Mon, 6 Sep 2021 12:38:46 +0200 Message-Id: <20210906103846.14941-3-marius@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210906103846.14941-1-marius@gnu.org> References: <20210906103846.14941-1-marius@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=1630925330; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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; bh=zVaRsRw9diUpz+YW1OW1mk2Yy//WliBrzfZdn3Th9BA=; b=aZLZNAI+eSk3YGTeoxXD9zv4JxBfpUpM8NWde25c9z0nWXL9wkOP6vGdbaajWiVEnU/KKn ETjm9uss3aOirrmsobzNhgZE99H38H3+f7EjDWzj/pyntNelAHXWzAIz4mQDszxpluCYpc Ul1VB/U42fON8HxNjhnOJ6dePITwbhb8iOEUFIT+7tmbYqK44Np+Voem4JX5lYVWLdxh47 EFisOdOwhRB7OLvah6L2i5grqtSjJNtq76Q+nM+cZhjPffK6ADaI73qMhzOLNT+sAeroOu OIrGjMbLqD4aEsTnuuU1UmLG+JG3Y/kdvHBMKZfWJEkYkmAsroDVlF88TEkRRA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630925330; a=rsa-sha256; cv=none; b=FeKsXOpCxQsZWF4GlSvBign1rtSXE8ZJEWRt6iLMGBFkCBYrGd6Oh/HBoxF+QwLKIkxjO9 1lITUtqDjGDiGcepLAD6SRlc3Ltb+1iK1o5ylTQcH4mwyOrofFPbge/AGgsUaaISgchcjl l4rOURIeIljgzdm7C3+EiFNWc68S37gzMLhajwhx5yCRGyFUcMF2/AVMHuVkjFm9OIYrow RYCdqBCx9E0Vct8btQpM+SYbEiT+kgCeVsvcdMFMg2Q0ubAl2B1fI4kb7VPT3wQ+7GCJFL 6wCa/Ym2JgHnd9PtsphWqWRK3oypJiWCmWZSfnCfEB2HGhgjoZVFzXQPqbz/Zw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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.91 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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: 7E999B2C2 X-Spam-Score: -1.91 X-Migadu-Scanner: scn0.migadu.com X-TUID: GoZAffKoFzFP * guix/transformations.scm (transform-package-source-commit): Look for 'git describe' style IDs and use it as the version if applicable. * tests/transformations.scm ("options->transformation, with-commit, 'git describe' style version"): New test. --- guix/transformations.scm | 37 ++++++++++++++++++++++++++++--------- tests/transformations.scm | 19 +++++++++++++++++++ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/guix/transformations.scm b/guix/transformations.scm index 5122baa403..af3eda76f8 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2021 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; @@ -278,15 +279,33 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using (define (replace old url commit) (package (inherit old) - (version (if (and (> (string-length commit) 1) - (string-prefix? "v" commit) - (char-set-contains? char-set:digit - (string-ref commit 1))) - (string-drop commit 1) ;looks like a tag like "v1.0" - (string-append "git." - (if (< (string-length commit) 7) - commit - (string-take commit 7))))) + (version (cond ((and (string-contains commit "-g") + (match (string-split commit #\-) + ((version ... revision g+commit) + (and (> (string-length g+commit) 4) + (string-every char-set:digit revision) + (string-every char-set:hex-digit + (string-drop g+commit 1)))) + (_ #f))) + ;; This looks like a 'git describe' style ID. Drop + ;; the 'v' prefix if applicable. + (if (and (string-prefix? "v" commit) + (char-set-contains? char-set:digit + (string-take + (string-drop commit 1) + 1))) + (string-drop commit 1) + commit)) + ((and (> (string-length commit) 1) + (string-prefix? "v" commit) + (char-set-contains? char-set:digit + (string-ref commit 1))) + (string-drop commit 1)) ;looks like a tag like "v1.0" + (else + (string-append "git." + (if (< (string-length commit) 7) + commit + (string-take commit 7)))))) (source (git-checkout (url url) (commit commit) (recursive? #t))))) diff --git a/tests/transformations.scm b/tests/transformations.scm index 3417c994ec..44fccffcce 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2021 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; @@ -235,6 +236,24 @@ (string=? (package-name dep2) "chbouib") (package-source dep2)))))))) +(test-equal "options->transformation, with-commit, 'git describe' style version" + "1.0-gcabba9e2" + (let* ((p (dummy-package "guix.scm" + (inputs `(("foo" ,grep) + ("bar" ,(dummy-package "chbouib" + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://example.org") + (commit "cabba9e"))) + (sha256 #f))))))))) + (t (options->transformation '((with-commit . "chbouib=v1.0-gcabba9e2"))))) + (let ((new (t p))) + (and (not (eq? new p)) + (match (package-inputs new) + ((("foo" dep1) ("bar" dep2)) + (package-version dep2))))))) + (test-equal "options->transformation, with-git-url" (let ((source (git-checkout (url "https://example.org") (recursive? #t)))) -- 2.31.1