From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uO6/B8C2M2HH1AAAgWs5BA (envelope-from ) for ; Sat, 04 Sep 2021 20:11:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id EKRrA8C2M2GiZgAA1q6Kng (envelope-from ) for ; Sat, 04 Sep 2021 18:11:12 +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 BBEB11644B for ; Sat, 4 Sep 2021 20:11:09 +0200 (CEST) Received: from localhost ([::1]:34290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMa8C-0007gu-Q7 for larch@yhetil.org; Sat, 04 Sep 2021 14:11:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMa87-0007fR-Ah for guix-patches@gnu.org; Sat, 04 Sep 2021 14:11:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMa87-0003Mj-2w for guix-patches@gnu.org; Sat, 04 Sep 2021 14:11:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mMa86-0003Y9-Uv for guix-patches@gnu.org; Sat, 04 Sep 2021 14:11:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50377] [PATCH 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: Sat, 04 Sep 2021 18:11:02 +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.163077904913614 (code B ref 50377); Sat, 04 Sep 2021 18:11:02 +0000 Received: (at 50377) by debbugs.gnu.org; 4 Sep 2021 18:10:49 +0000 Received: from localhost ([127.0.0.1]:48548 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMa7t-0003XW-9f for submit@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMa7r-0003X4-Cu for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:47 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39922) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMa7m-00035s-8Y for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:42 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38036 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMa7k-0005BX-Ax for 50377@debbugs.gnu.org; Sat, 04 Sep 2021 14:10:42 -0400 From: Marius Bakke Date: Sat, 4 Sep 2021 20:10:35 +0200 Message-Id: <20210904181035.24161-2-marius@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210904181035.24161-1-marius@gnu.org> References: <20210904180845.23915-1-marius@gnu.org> <20210904181035.24161-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=1630779069; 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=droaz0MONSSKjmLFL7fvWpZfiGaBv+tS47K+AHNqkAg=; b=JtgnrZcMpBjVW3hTuZsAvd2HqKiJeANdbt7QAES1yRDKcCpVB36WNjIeBGnMpIJJeiZuyA Yj91/4tpkHRhHLOlZYi9aOVmE0h7o/PL1IsIHysGW5H9DQqzzrN2Yj0icOKr40dF34le1d g94cds6eKZmMc7OemzStwUvNtcGvqtajVgKFM4szHIiKEzrxGQWliXhi8ONjA9yp2KMt+3 MJNBqa0X5gzPwfCEAe0bBksbXsu86YJkSqCItkXF1f9X8NzkkA6FoLrCVThO7Knto6hMLJ 5Ff3m6p9Q0sAJLnOhqK1WKUqKUkVHLyVDrT2gMZ7qwGa+rBv95lbHgx9zVkXsw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630779069; a=rsa-sha256; cv=none; b=e+ymiwc8k5lqD9DSmfnJuGnMbaZR1pdP3LdsdB1CuQrX/RGS/VBj7KZA2I2frPqQS9o9eF B90vKaZ2lvVFD4HkXYZFU6xKjmvUoDQCc3td/MvnJYkjYYj+H1hTFWAYaDx7MFpvreG9HR I6bC0hAUD78fqPJtI2+DQUEWNI0aYskuXg3zf0BZgl9ukOdXcjMQ6X/tr4m07SmnoWSsip fkeMOBxL3BHrcBjX96RFsAHupXFG3QQDL1Tjm1v6E57B/75DoaMjWL1UIxCog3qZwZcb7K ClcKuwUQ8+06Lay0JWyCoYya6X/Xj6qg0eumRY+g+T38evSgXMrNEJN8/oTgrw== 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: -0.42 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: BBEB11644B X-Spam-Score: -0.42 X-Migadu-Scanner: scn1.migadu.com X-TUID: z4sZFurz+kE4 * 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 | 34 +++++++++++++++++++++++++--------- tests/transformations.scm | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/guix/transformations.scm b/guix/transformations.scm index 5122baa403..e91bce3808 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,30 @@ 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-length commit) 8) + (string-contains commit "-g") + (match (string-split commit #\-) + ((components ... g+id) + (char-set-every (cut char-set-contains? + char-set:hex-digit <>) + (string->char-set + (string-drop g+id 1)))) + (_ #f))) + ;; This looks like a 'git describe' style ID. Drop + ;; the 'v' prefix if applicable. + (if (string-prefix? "v" commit) + (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