From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id UPznDOWBb2RdagAASxT56A (envelope-from ) for ; Thu, 25 May 2023 17:42:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id UDYODOWBb2QahAEAG6o9tA (envelope-from ) for ; Thu, 25 May 2023 17:42:29 +0200 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 AB1A738AC7 for ; Thu, 25 May 2023 17:42:28 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2D6M-0001Wi-V9; Thu, 25 May 2023 11:42:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2D6J-0001VX-Dl for guix-patches@gnu.org; Thu, 25 May 2023 11:42:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2D6J-0002Wz-5P for guix-patches@gnu.org; Thu, 25 May 2023 11:42:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q2D6J-00018i-1O for guix-patches@gnu.org; Thu, 25 May 2023 11:42:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63647] [PATCH v2 3/3] guix: import: go: Use correct tag for go module in subdirectory. Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 25 May 2023 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63647 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63647@debbugs.gnu.org Cc: Stephen Paul Weber , Simon Tournier Received: via spool by 63647-submit@debbugs.gnu.org id=B63647.16850292934294 (code B ref 63647); Thu, 25 May 2023 15:42:02 +0000 Received: (at 63647) by debbugs.gnu.org; 25 May 2023 15:41:33 +0000 Received: from localhost ([127.0.0.1]:47887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2D5o-000176-Ef for submit@debbugs.gnu.org; Thu, 25 May 2023 11:41:32 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:39216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2D5j-00016P-29 for 63647@debbugs.gnu.org; Thu, 25 May 2023 11:41:27 -0400 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3094ca1df73so351039f8f.1 for <63647@debbugs.gnu.org>; Thu, 25 May 2023 08:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685029281; x=1687621281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IGxbiqGMkKYf02xQ8jmP+1cjWMBkw0vK+f7mNuPZKsU=; b=AwAM8Mbfox6ZsJHJ3tTx8T8cdLp4hF4jq/7MzTymlI73V+ugGVfH5O0//R7cpVJ6ni PUgdmp2t+H/Kad7K3vINdsc01CGxjwb2EaH3iXJLSLBPa/TMPS7evAMmuqXLSVpGmPbS ef8QRRNQUSx7ZUDHTAczTGPwFrVZG+jpnjmbjorUeFYWSgjMUOl1zMueH5X5NLHTa1/f AgKlmcqZHuJR9XAUHu89RBBPKAGZ8ODmK5UKs40EKRcQOVigM0rkX5gsdzDXUyxAViNu 2HY2DSOiZg6Fc6zAx2gerBl9qbzsikDkl65AMYpEyPAmb+lyvsX+DO85YWWP1s+3s4rz ES0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685029281; x=1687621281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IGxbiqGMkKYf02xQ8jmP+1cjWMBkw0vK+f7mNuPZKsU=; b=It7Z4nQ/8OIdDJwLd+UU3nR95xoL6jZZEI/kuI9a/7l62sACGGNz9AGhzWtchMhIFt ZJwVUGA5TQLPWP4FOf8Yu3psWzfVLjJMjU9kLA26POCVaqZb4V3bxQRc3rS1IKrVzonv G3deyzl7yHO5PVABUJ6VocAgpRTFM0iTanT3MZD6/NHnHaURlAUvRAQmUNgZUEGBRkr5 9EAUsQxoWtf6G1ZQ7BluQSk3henerM+nn1RgrkByTxl2Qg+lGAEU/cYK4agArcdK2lr0 jeAE5PSO/Xy+pfHF2bHeqx7roUNJytlIVyMJjhBuicwr0DewhkHGgzzHnNXnXSjopADn Eemw== X-Gm-Message-State: AC+VfDwaQzdqbY0rS7gQCqcP4oBJ57DaA2WpIHc78xk8HARHYcY9uD7v bFuZhPpD7pRFDS4jnUme9HVJJoc0AEs= X-Google-Smtp-Source: ACHHUZ49WiwBhudrYrPWaB2bb2oNVSnz7fSIcpvsObs/F4GdWCP+Sj/rmmxmtEPHg/TfRStFd8ncBA== X-Received: by 2002:a5d:6208:0:b0:2f9:59a3:eb30 with SMTP id y8-20020a5d6208000000b002f959a3eb30mr13358506wru.0.1685029280975; Thu, 25 May 2023 08:41:20 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id q2-20020adff502000000b003062c0ef959sm2172258wro.69.2023.05.25.08.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 08:41:20 -0700 (PDT) From: Simon Tournier Date: Thu, 25 May 2023 17:41:12 +0200 Message-Id: <27b0652df204a77a5b38554a95128fb54ca64dd9.1685029183.git.zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685029348; a=rsa-sha256; cv=none; b=gVGDRW9Y3asa7+lJirvc188Z9OwUjA3q+3l/xsAwVGlhWt5IXeDo8uHMXIcBkxWeT9RYxD 53ZfsehY5O/TKBx+/5CztJErvJnMLNaQUKN0ezpthjex2WrFTF0FjtNONqQBaLHT05gscc 7B+XkAmcqJS06dvR/eZaSJfWgNLCxvu6E17jck40TNnhdZ1GIDDakIY+nfSerRWLoVqT4h K3Rrb2lx2cSs9fWKDx5uiZxM5kjBFzYHA524qXFXKO4c4HJcw/1GtvzCkbZ7VgUabkHAOK 0rM4pv7UkDuVl/YMo9KtBY/KQ2cRHdG7Nmhq1/r45pc3zlmMqviFnjeC3Y+TXw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=AwAM8Mbf; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685029348; 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=IGxbiqGMkKYf02xQ8jmP+1cjWMBkw0vK+f7mNuPZKsU=; b=PDJt7Bu1Pzhs1aghOGGLwXgGewezYZgoTBsKL9Sy1TGFqJDX8fJ6fRCxD5NUDEXsxSvFhS cq/ILzJ7D5Js5CN2cOviasNL/qH14PCH2kCqMAles6S66IgTnlEnPClfQaimwgqIgvsk7Q h4J7uqcD8Nd/PAYpjqTbmz19HAMCZDpN6ASttqwbv7hkuh9jsfp6I4BMDmBuOxKtbwdkr0 KWPhsfCQpSPxhNfVMjsM6kBHOGAo7oSiVECrNmDUVKGTBNWgIJUmS7DZ7x2W2YfXIJGg88 1dbLfTVY+kDCJDaoxxArITN7jXdOsXOJkjF3/sLnLJBEPDQU3q5uQcPBliriBw== X-Migadu-Spam-Score: -3.37 X-Spam-Score: -3.37 X-Migadu-Queue-Id: AB1A738AC7 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20221208 header.b=AwAM8Mbf; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-TUID: VtcOJR3biX8j From: Stephen Paul Weber * guix/import/go.scm (vcs->origin): New argument module-path-subdirectory. Use it to get Git tag as described by . Signed-off-by: Simon Tournier --- guix/import/go.scm | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index c6258296f6..f02c098f1c 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2021-2022 Ludovic Courtès ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021 Sarah Morgensen +;;; Copyright © 2022 Stephen Paul Weber ;;; Copyright © 2021, 2023 Simon Tournier ;;; ;;; This file is part of GNU Guix. @@ -522,28 +523,34 @@ (define* (git-checkout-hash url reference algorithm) (nix-base32-string->bytevector "0000000000000000000000000000000000000000000000000000")))) -(define (vcs->origin vcs-type vcs-repo-url version) +(define (vcs->origin vcs-type vcs-repo-url module-path-subdirectory version) "Generate the `origin' block of a package depending on what type of source control system is being used." (case vcs-type ((git) - (let ((plain-version? (string=? version (go-version->git-ref version))) - (v-prefixed? (string-prefix? "v" version))) + (let* ((plain-version? (string=? version (go-version->git-ref version))) + (v-prefixed? (string-prefix? "v" version)) + ;; A module in a subdirectory has a tag prefixed by this + ;; subdirectory. See . + (tag-prefix (if (string=? module-path-subdirectory "") ; + "" + (string-append + (substring module-path-subdirectory 1) "/"))) + (git-commit (if plain-version? + (string-append tag-prefix version) + (go-version->git-ref version)))) `(origin (method git-fetch) (uri (git-reference (url ,vcs-repo-url) - ;; This is done because the version field of the package, - ;; which the generated quoted expression refers to, has been - ;; stripped of any 'v' prefixed. (commit ,(if (and plain-version? v-prefixed?) - '(string-append "v" version) + `(string-append ,tag-prefix "v" version) '(go-version->git-ref version))))) (file-name (git-file-name name version)) (sha256 (base32 ,(bytevector->nix-base32-string - (git-checkout-hash vcs-repo-url (go-version->git-ref version) + (git-checkout-hash vcs-repo-url git-commit (hash-algorithm sha256)))))))) ((hg) `(origin @@ -621,12 +628,17 @@ (define* (go-module->guix-package module-path #:key dependencies+versions (map car dependencies+versions))) (module-path-sans-suffix - (match:prefix (string-match "([\\./]v[0-9]+)?$" module-path))) + (if (string-prefix? "gopkg.in" module-path) + module-path + (match:prefix (string-match "([\\./]v[0-9]+)?$" module-path)))) (guix-name (go-module->guix-package-name module-path)) - (root-module-path (module-path->repository-root module-path)) + (root-module-path (module-path->repository-root module-path-sans-suffix)) ;; The VCS type and URL are not included in goproxy information. For ;; this we need to fetch it from the official module page. (meta-data (fetch-module-meta-data root-module-path)) + (module-path-subdirectory + (substring module-path-sans-suffix + (string-length (module-meta-import-prefix meta-data)))) (vcs-type (module-meta-vcs meta-data)) (vcs-repo-url (module-meta-data-repo-url meta-data goproxy)) (synopsis (go-package-synopsis module-path)) @@ -637,7 +649,7 @@ (define* (go-module->guix-package module-path #:key (name ,guix-name) (version ,(strip-v-prefix version*)) (source - ,(vcs->origin vcs-type vcs-repo-url version*)) + ,(vcs->origin vcs-type vcs-repo-url module-path-subdirectory version*)) (build-system go-build-system) (arguments '(#:import-path ,module-path -- 2.38.1