From patchwork Mon Sep 6 10:38:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marius Bakke X-Patchwork-Id: 32662 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 36CE527BBE3; Mon, 6 Sep 2021 11:39:10 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EE02327BBE1 for ; Mon, 6 Sep 2021 11:39:09 +0100 (BST) Received: from localhost ([::1]:38432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNC1s-0001td-SD for patchwork@mira.cbaines.net; Mon, 06 Sep 2021 06:39:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNC1m-0001su-9C for guix-patches@gnu.org; Mon, 06 Sep 2021 06:39:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNC1l-0001tA-UJ for guix-patches@gnu.org; Mon, 06 Sep 2021 06:39:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mNC1l-0002lW-Rt for guix-patches@gnu.org; Mon, 06 Sep 2021 06:39:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50377] [PATCH v3 1/2] git: 'resolve-reference' handles 'git describe'-style commit IDs. Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 06 Sep 2021 10:39: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.163092474010623 (code B ref 50377); Mon, 06 Sep 2021 10:39:01 +0000 Received: (at 50377) by debbugs.gnu.org; 6 Sep 2021 10:39:00 +0000 Received: from localhost ([127.0.0.1]:52058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1k-0002lH-Dv for submit@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36366) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNC1j-0002l3-GF for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:39:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35076) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNC1e-0001nU-9p for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:54 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38042 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNC1d-0008F8-Ml for 50377@debbugs.gnu.org; Mon, 06 Sep 2021 06:38:54 -0400 From: Marius Bakke Date: Mon, 6 Sep 2021 12:38:45 +0200 Message-Id: <20210906103846.14941-2-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 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" X-getmail-retrieved-from-mailbox: Patches * guix/git.scm (resolve-reference): Rewrite tag-or-commit case to recognize 'git describe' style identifiers and resolve them as commits. --- guix/git.scm | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/guix/git.scm b/guix/git.scm index 9c6f326c36..621de0e925 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2017, 2020 Mathieu Othacehe ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2021 Kyle Meyer +;;; Copyright © 2021 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; @@ -223,15 +224,29 @@ corresponding Git object." (object-lookup-prefix repository (string->oid commit) len) (object-lookup repository (string->oid commit))))) (('tag-or-commit . str) - (if (or (> (string-length str) 40) - (not (string-every char-set:hex-digit str))) - (resolve `(tag . ,str)) ;definitely a tag - (catch 'git-error - (lambda () - (resolve `(tag . ,str))) - (lambda _ - ;; There's no such tag, so it must be a commit ID. - (resolve `(commit . ,str)))))) + (cond ((and (string-contains str "-g") + (match (string-split str #\-) + ((version ... revision g+commit) + (if (and (> (string-length g+commit) 4) + (string-every char-set:digit revision) + (string-every char-set:hex-digit + (string-drop g+commit 1))) + (string-drop g+commit 1) + #f)) + (_ #f))) + ;; Looks like a 'git describe' style ID, like + ;; v1.3.0-7-gaa34d4d28d. + => (lambda (commit) (resolve `(commit . ,commit)))) + ((or (> (string-length str) 40) + (not (string-every char-set:hex-digit str))) + (resolve `(tag . ,str))) ;definitely a tag + (else + (catch 'git-error + (lambda () + (resolve `(tag . ,str))) + (lambda _ + ;; There's no such tag, so it must be a commit ID. + (resolve `(commit . ,str))))))) (('tag . tag) (let ((oid (reference-name->oid repository (string-append "refs/tags/" tag))))