From patchwork Thu May 25 16:07:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 50323 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 B346A27BBEA; Thu, 25 May 2023 17:09:42 +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 9578D27BBE2 for ; Thu, 25 May 2023 17:09:41 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2DWT-0008Q0-Pq; Thu, 25 May 2023 12:09:05 -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 1q2DWQ-0008KQ-U5 for guix-patches@gnu.org; Thu, 25 May 2023 12:09:02 -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 1q2DWQ-0003Kx-La for guix-patches@gnu.org; Thu, 25 May 2023 12:09:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q2DWQ-00022S-26 for guix-patches@gnu.org; Thu, 25 May 2023 12:09:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63647] [PATCH v3 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 16:09: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.16850308877754 (code B ref 63647); Thu, 25 May 2023 16:09:02 +0000 Received: (at 63647) by debbugs.gnu.org; 25 May 2023 16:08:07 +0000 Received: from localhost ([127.0.0.1]:47927 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2DVW-00020z-An for submit@debbugs.gnu.org; Thu, 25 May 2023 12:08:06 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:38329) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2DVS-00020H-Vz for 63647@debbugs.gnu.org; Thu, 25 May 2023 12:08:05 -0400 Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-30aa563abdaso277564f8f.1 for <63647@debbugs.gnu.org>; Thu, 25 May 2023 09:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685030877; x=1687622877; 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=ggyHuW7W6dj1cM2DJo0LS2NRgbC0S+NSoOr7/aVuNQ8=; b=jN1ac2yKpQOfOCkANizpmgEKAwubPZfjjQsW6oi9dZdm4XqNw9GDHG0hD4F7d+e8r9 /HTyFX1vmgl6kU7SjpAA5mFLGhk28Q/39HyPufDkcIm7xS7zo6DUV3IEMrUR0a2DYwun oRzOOcibP5XVxjM/uYc3pvZLlTipc1wv9V6iGlyDY7qaBbciAkHjGDChsrl1w303wATk Fw8uBIae6ZwR8fijHvQerCan8sIVBCIvHTDc2UJHbe5ZrbVsYdFwaHn9ooJCXx4oBlv1 lQEf7Tu6AKJdSfGSL63lmlFIvN8E+pCgSOOGqclxLDcTYbHK6r0uk2lOTaK/g3C5lWSO N1Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685030877; x=1687622877; 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=ggyHuW7W6dj1cM2DJo0LS2NRgbC0S+NSoOr7/aVuNQ8=; b=lYF00BKtKCUr/AiStn+YvW3KBPPi5ZfRysD/Q7AS3WPoABw47v5qapsg9v6L+1khsd YAy9rrhxT5j5MIwmCxOw4DoPDh3aEnHmCguv0PBtoW6T4BnRg54qJGTHrmMy7WcakZlp JdE8Rm42lJfrYrh5oInqmM503CXKvBGHHvmRWxzm2hmPt6K/biNgV+kmakL9Cm5rBgNu E5FYGKZeDH8p7isScxYu3ZQZW/eatlUVhUNFACJsS2OirW5qaDwr17YKVTl9xYRT/Utl i6teU/TBId53VpNhLqE1WtJBJBY39f4s82+TAnHP9Tm04inmp3Ik8XMPloWI9IPebsy3 yLLA== X-Gm-Message-State: AC+VfDy3FyWK3MmWEgENFmPgcpYeVJztTMGTFlFm+DCQjdr1/QUqsLTX 9sBOrPHkG3cCHsKZIM8Qy+jPqKqlPPw= X-Google-Smtp-Source: ACHHUZ46H/nQardfTYlQ1ZPE74pM4L7Sl/TEQEqVaz+a6KOSiH1wfBb0vczZNHaS46ezFCCxReh/IA== X-Received: by 2002:adf:e345:0:b0:307:a582:330a with SMTP id n5-20020adfe345000000b00307a582330amr4093110wrj.2.1685030877123; Thu, 25 May 2023 09:07:57 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id y9-20020a5d4709000000b00307d58b3da9sm2261016wrq.25.2023.05.25.09.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 09:07:56 -0700 (PDT) From: Simon Tournier Date: Thu, 25 May 2023 18:07:49 +0200 Message-Id: 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 . Co-authored-by: Simon Tournier Signed-off-by: Simon Tournier --- guix/import/go.scm | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index c6258296f6..c2f9065d94 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,35 @@ (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) "/"))) + (prefix (string-append tag-prefix "v")) + (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 ,prefix 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 +629,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 +650,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