From patchwork Sun Sep 5 22:52:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marius Bakke X-Patchwork-Id: 32652 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 9000127BBE3; Sun, 5 Sep 2021 23:53:14 +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 492D327BBE1 for ; Sun, 5 Sep 2021 23:53:14 +0100 (BST) Received: from localhost ([::1]:46576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mN10j-0003ux-7e for patchwork@mira.cbaines.net; Sun, 05 Sep 2021 18:53:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mN10Z-0003ul-Aw for guix-patches@gnu.org; Sun, 05 Sep 2021 18:53:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mN10Z-0001NK-4A for guix-patches@gnu.org; Sun, 05 Sep 2021 18:53:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mN10Z-0000Xs-3C for guix-patches@gnu.org; Sun, 05 Sep 2021 18:53:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50377] [PATCH v2 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: Sun, 05 Sep 2021 22:53:03 +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.16308823392027 (code B ref 50377); Sun, 05 Sep 2021 22:53:03 +0000 Received: (at 50377) by debbugs.gnu.org; 5 Sep 2021 22:52:19 +0000 Received: from localhost ([127.0.0.1]:51148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mN0zr-0000Wc-8r for submit@debbugs.gnu.org; Sun, 05 Sep 2021 18:52:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42164) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mN0zp-0000WM-Hm for 50377@debbugs.gnu.org; Sun, 05 Sep 2021 18:52:17 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47120) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mN0zk-0000q5-AS for 50377@debbugs.gnu.org; Sun, 05 Sep 2021 18:52:12 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38038 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mN0zj-0003Ad-IA for 50377@debbugs.gnu.org; Sun, 05 Sep 2021 18:52:12 -0400 From: Marius Bakke In-Reply-To: <20210904181035.24161-1-marius@gnu.org> References: <20210904180845.23915-1-marius@gnu.org> <20210904181035.24161-1-marius@gnu.org> Date: Mon, 06 Sep 2021 00:52:08 +0200 Message-ID: <87pmtmprdz.fsf@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 Marius Bakke skriver: > * guix/git.scm (resolve-reference): Use REVPARSE-SINGLE for looking up > commits. Rewrite tag-or-commit case to recognize 'git describe' style > identifiers and resolve them as commits. I realize we can do this without resorting to 'revparse-single', which does essentially the same as this procedure. We just have to extract the short commit from the describe string. New patch attached: From 9af0f5fd7d8209ffe94d9e0007f58a1a475fe4f1 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Mon, 6 Sep 2021 00:21:51 +0200 Subject: [PATCH] git: 'resolve-reference' handles 'git describe'-style commit IDs. * guix/git.scm (resolve-reference): Rewrite tag-or-commit case to recognize 'git describe' style identifiers and resolve them as commits. --- guix/git.scm | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/guix/git.scm b/guix/git.scm index 9c6f326c36..09efab1182 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,28 @@ 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) 7) + (string-every char-set:digit revision) + (string-every char-set:hex-digit + (string-drop g+commit 1))) + ;; Looks like a 'git describe' style id, like + ;; v1.3.0-7-gaa34d4d28d. + (resolve `(commit . ,(string-drop g+commit 1))) + #f)) + (_ #f)))) + ((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)))) -- 2.31.1