From patchwork Mon Dec 19 15:02:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 2927 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp3074951dyk; Mon, 19 Dec 2022 07:03:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXvOfXeZsGGFYgW1ukDeZ/Jm+o4FBETE6PDRdKPqvakwL+9X0faeuTZbmpmdI8IzqCEcGJsY X-Received: by 2002:a05:6102:21db:b0:3bc:e711:1844 with SMTP id r27-20020a05610221db00b003bce7111844mr1871708vsg.20.1671462205505; Mon, 19 Dec 2022 07:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671462205; cv=none; d=google.com; s=arc-20160816; b=fxpsRTwW8e4qQ5WGv4hrZDKwzVjhv62jQTjyVvBSA1+CN2F+fvUEvytL8MMj9XkevQ x1m5JdCCEOz9453cdosBSzW3uNuaOCHqBYmMWG6NYyaIgkR/7bqGainRUPTYWnNcMOxD JfRPKHjBYr43BQ4/ax6E3A3/Dn4I8jaWKFWHTfa2AxqWCH2iUVb+PL807vmfv4M6psBW cGSA0Ox4mjXTEGFhs10S9/y5w1IjdQXDv9z7M+OiPPalCimimHnxKboQY9UNMgapl5YK S6OroqGIKzQjDSu8SeELGzFfUmnoCJa/hdbNZdfckieJaQIQ/RKW/U7C4MynCoYmCNZx rpMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:cc:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=FJkDfiUb4xQqORsYtCj1hAiyUlVC8eA49QG+XTdxeiY=; b=PNbfKSYlGIQorlnvkfpU33fstVTnHQAQhpI+NHgVRN/tekKHiz2NslWHF9+bn3tnXQ RWVQU2EuKHW3ITX/1s/6zK++VnBoY44DsQgsk9k3gi7eBOUyLagfMeodh53lIJdocaQd gCiqNeImaPh4W/doFwisZD9WXYBBQOCGXq2bJDOJrtwZCJDOH0LOtu5cBllsCvCuPZ/z 5SPVGJPyFvM3yNP6v5l1iMuR6Nn/mhScfNJa3wATjwMm9XLiIME4VHnu7upZzY9+w7ba jX1vP/vgc5fd7/p9hQB0w2e2mI3UrcT+SeIemeZE9c82YOM7YAIZH493eKc33UwgMnjz 4TUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Zl5TrYyM; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Kizu5hMr; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="nL5U5n8/"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id e20-20020a67e194000000b003b076319865si2024012vsl.466.2022.12.19.07.03.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2022 07:03:25 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Zl5TrYyM; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Kizu5hMr; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="nL5U5n8/"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1p7HfL-0008JZ-63; Mon, 19 Dec 2022 15:02:55 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1p7HfJ-0008JD-Ew for openvpn-devel@lists.sourceforge.net; Mon, 19 Dec 2022 15:02:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7x2Q5989Ino+M+acfMFsn/Z7JcOTDKscXyrAQgsOuK8=; b=Zl5TrYyMvL/erzJOXSSdIBXhFJ 2HWp1B89M1oX+aJY7NE9l8IYu929Kq7M81IhqTBeDRBVMkQ+IIdbFeJGLKNf6AxInf2uOsEx8jJ/W tM2awGFuei+AXpBeZjQFbPxCCpvBeMMIojA8BW1NSAeAm8PS0fp0FjubjcpZX1cxF3Vw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7x2Q5989Ino+M+acfMFsn/Z7JcOTDKscXyrAQgsOuK8=; b=Kizu5hMriNfLZJmOmpmjyoa2a7 AbttnZTlNvzXE9ys4HUpeE8detmBUy3SGUYNEWuLqOynpAk+Fgm9l1cZh5Vu10xEvZAFbefJ976xD spZjA8dCPYUzmIqCBEHo6UIURIH+Ii4WaQ5cwftnBwzvQUYws1gWzMZmCKsR/MwrsyfU=; Received: from mail-lf1-f44.google.com ([209.85.167.44]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1p7HfH-0007wO-Ki for openvpn-devel@lists.sourceforge.net; Mon, 19 Dec 2022 15:02:53 +0000 Received: by mail-lf1-f44.google.com with SMTP id 1so14068674lfz.4 for ; Mon, 19 Dec 2022 07:02:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=7x2Q5989Ino+M+acfMFsn/Z7JcOTDKscXyrAQgsOuK8=; b=nL5U5n8/ygDWOSpwK6aOKcYMNJOm/JpQGe8BaDEwyHBdJI6wNRHGDvgmXjdmjHqb2g fw+DFSAuniTfrDHMLzIDOkA7q+NLONk7VrX16ozCm+KTztMLCNlBnzpr4BcCHFJT/tW3 GRj9Mt0sL/BjLKyOwAZOj1z3lslE2TM0hLwcxCwBoAvLCH6aREFgpaIfRdKVyNcvOG3j muY5C3qOQ/8PuOrbGaSvZzue3lN1R4XB4ZuPB43HYqrhmQW6sWboBg18xzVO5EbgXRJF +ESF8FhcuyOT9Fk7iRIFjSPkHvks6OgonGbf9AhUnN5b4loGw51xvUUkjmGBs6dcxK/B jKZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=7x2Q5989Ino+M+acfMFsn/Z7JcOTDKscXyrAQgsOuK8=; b=5bkvJ9sw8Xx/2Pxv8Y8TCn69AKemu/bniVdt6OSOuoPLlH7yE5aOiyRJ5Y1MroBDDn Gkgnv5bBn1KRVFucsIOBXRRNH9Z8/iXrRxRpjgWX9hWv6SEcDu6M9lK1ayw6G2oGJN9m gf6K/dRdhob3ZjuX5JeBHCLttd/MkHhYTfgDhZgFU9e8q4w6a8nCrxnNOxQ6dwWa5d2z XBgeahOJletOK7ENROXSOnqWt06JrwJCqEgx87PCJgN04ZsWwr8B1Q2FVjP3DpDXsBmd 2IoDir299UonCDHRUkNsjDEjE7jgX7Gar3DU0Bw4BZ6Uj0lY4sFsKRdOpIu1H1IOg2rJ IXxw== X-Gm-Message-State: ANoB5plIaWVlppfTGItoeWQGWbYNr80h1TZaqOaeXxKeA1WS2RWoUZ6z Sd1t+0G1z5boht5ELzHjBRscsZTkFHY= X-Received: by 2002:a05:6512:1115:b0:4b5:b7ba:cae with SMTP id l21-20020a056512111500b004b5b7ba0caemr12277946lfg.48.1671462164568; Mon, 19 Dec 2022 07:02:44 -0800 (PST) Received: from LAPTOP-4L3N7KFS.localdomain (81-175-157-115.bb.dnainternet.fi. [81.175.157.115]) by smtp.gmail.com with ESMTPSA id a1-20020a056512200100b004b097f2c73dsm1125670lfb.253.2022.12.19.07.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 07:02:44 -0800 (PST) From: Lev Stipakov To: openvpn-devel@lists.sourceforge.net Date: Mon, 19 Dec 2022 17:02:26 +0200 Message-Id: <20221219150226.467-1-lstipakov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Lev Stipakov Git magic to get branch name git rev-parse --symbolic-full-name HEAD Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.44 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [lstipakov[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.44 listed in wl.mailspike.net] X-Headers-End: 1p7HfH-0007wO-Ki Subject: [Openvpn-devel] [PATCH v2] git-version.py: proper support for tags X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lev Stipakov Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1752655154039026004?= X-GMAIL-MSGID: =?utf-8?q?1752655154039026004?= From: Lev Stipakov Git magic to get branch name git rev-parse --symbolic-full-name HEAD doesn't work when we're on tag, which is the case when we build releases. First, try to get tag name with git describe --exact-match and if this fails, get branch name as before. Use subprocess.Popen() to suppress stdout/stderr output. This fixes https://github.com/OpenVPN/openvpn/issues/199. Signed-off-by: Lev Stipakov --- v2: - try to get tag name before branch - use "git describe --exact-match" instead of "git describe --tags" - use subprocess.Popen() instead of os.popen() to suppress output build/msvc/msvc-generate/git-version.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/build/msvc/msvc-generate/git-version.py b/build/msvc/msvc-generate/git-version.py index 814dc86a..89fd44f2 100644 --- a/build/msvc/msvc-generate/git-version.py +++ b/build/msvc/msvc-generate/git-version.py @@ -24,15 +24,22 @@ import os import sys +import subprocess + +def run_command(args): + sp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + o, _ = sp.communicate() + return o.decode("utf-8")[:-1] def get_branch_commit_id(): - commit_id = os.popen("git rev-parse --short=16 HEAD").read()[:-1] + commit_id = run_command(["git", "rev-parse", "--short=16", "HEAD"]) if not commit_id: raise - l = os.popen("git rev-parse --symbolic-full-name HEAD").read().split("/")[2:] - if not l: - l = ["none\n"] - branch = "/" .join(l)[:-1] + branch = run_command(["git", "describe", "--exact-match"]) + if not branch: + branch = run_command(["git", "rev-parse", "--symbolic-full-name", "HEAD"]).split("/")[2:] + branch = "/" .join(branch) # handle cases like release/2.6 + return branch, commit_id def main():