From patchwork Thu May 25 15:41:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 50319 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 210CE27BBE9; Thu, 25 May 2023 16:42:30 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9ECE327BBE2 for ; Thu, 25 May 2023 16:42:28 +0100 (BST) 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 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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