From nobody Mon Feb 9 23:14:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+51789+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51789+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575562388; cv=none; d=zohomail.com; s=zohoarc; b=EcHeJcmlUHOzuLTmmghjz7AogBcRHRXHQEtWChTOQVlN92lO0RB0tLBBAD3fE+30+J1O7zReN2UlL5Bi8q270g8NgQtUtVywkUx2Cck28O38Scsj/9+jan35KXYwI4CZfaacqa75yvxCP7UX4GvVFeMZ7bpvBPq0mCS32SDtlbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575562388; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hGdCMD0orYXgosYELhxdNO+bFheoXHB4KlRRT8PavwE=; b=J/FqAEWtsYnK4Uo4xmQd1L1fEUbmHqx6bIqmI2/See1MHiR+2nq1uG47XOCy4ybD4CtX581KTUpxMhCMuD92EDDcN8AVWMaFkTzzImGPObjoePyHTPFrd2D9h+Jr2HhHrxUSEjUiUW8b6OYnZ2NGc3eGn/3r/FdqNTFYcKTAwpc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+51789+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1575562388167832.8962697329482; Thu, 5 Dec 2019 08:13:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Thu, 05 Dec 2019 08:13:07 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web12.11650.1575562374646797441 for ; Thu, 05 Dec 2019 08:12:54 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-pWhh5QBNMP2O-7j4bI1DRw-1; Thu, 05 Dec 2019 11:12:49 -0500 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0C9112D6581; Thu, 5 Dec 2019 16:12:48 +0000 (UTC) X-Received: from x1w.redhat.com (ovpn-205-76.brq.redhat.com [10.40.205.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E366110013D9; Thu, 5 Dec 2019 16:12:45 +0000 (UTC) From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= To: devel@edk2.groups.io Cc: Philippe Mathieu-Daude , Bob Feng , Liming Gao , Laszlo Ersek , Ard Biesheuvel , Leif Lindholm Subject: [edk2-devel] [PATCH 3/6] BaseTools/Scripts: Add GitPostCommitHook.py Date: Thu, 5 Dec 2019 17:12:31 +0100 Message-Id: <20191205161234.25071-4-philmd@redhat.com> In-Reply-To: <20191205161234.25071-1-philmd@redhat.com> References: <20191205161234.25071-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: pWhh5QBNMP2O-7j4bI1DRw-1 X-Mimecast-Spam-Score: 0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,philmd@redhat.com X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1575562387; bh=hWqLpkCN5qxX+iJYvqiDyC1qgkiyPtOZPnS7/brCVjg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=O0CUIVyxeMoM+DBjVMmJLYYVxL8MQFS1WAajt1pBjxMXjC4GUZC5B3AaHNeW2YC6IOv Vx41M3z8l9GHhI+E1vz/gHRoXD+DZfw+UI7+9/MEkvpxi1o6clKxCFUrCFJCCmqqHCJBZ WTvpTXwtk8ksK3+MM4GH4GZKQnbNpxWndCs= X-ZohoMail-DKIM: pass (identity @groups.io) Git allows the use of various hooks (see [*]). In particular it provides the 'post-commit' hook, which is a convenient place to run the PatchCheck script. [*] https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks Cc: Bob Feng Cc: Liming Gao Signed-off-by: Philippe Mathieu-Daude --- I'm hitting a egg/chicken problem here. If I add this script without CRLF, PatchCheck complains: Code format is not valid: * Line ending ('\n') is not CRLF File: BaseTools/Scripts/GitPostCommitHook.py Line: #!/usr/bin/python However if I convert it to CRLF, then Linux does not recognize the shebang, and if I symlink the script, when the hook is executed I get: fatal: cannot run .git/hooks/post-commit: No such file or directory Because the interpreter expects the shebang line with Unix line ending (linefeed only). As a kludge I'm happy using: $ echo > .git/hooks/post-commit #!/bin/sh test -e BaseTools/Scripts/GitPostCommitHook.py && exec python3 BaseTools/= Scripts/GitPostCommitHook.py EOF $ chmod +x .git/hooks/post-commit (The 'test' allow to checkout to older references where the script is not available). Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Leif Lindholm --- BaseTools/Scripts/GitPostCommitHook.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 BaseTools/Scripts/GitPostCommitHook.py diff --git a/BaseTools/Scripts/GitPostCommitHook.py b/BaseTools/Scripts/Git= PostCommitHook.py new file mode 100755 index 000000000000..4ea933a7eedf --- /dev/null +++ b/BaseTools/Scripts/GitPostCommitHook.py @@ -0,0 +1,21 @@ +#!/usr/bin/python +## @file +# Run PatchCheck on the last commit. +# +# Copyright (c) 2019, Red Hat, Inc. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# To have git run this script after each commit, create a symbolic +# link or copy it to .git/hooks/post-commit in your EDK2 repository. + +import os +import sys + +if __name__ =3D=3D '__main__': + sys.path.append(os.path.join(os.environ['EDK_TOOLS_PATH'], 'Scripts')) + from PatchCheck import CheckGitCommits, Verbose + Verbose.level =3D Verbose.QUIET + GIT_REFERENCE =3D 'HEAD' + COMMIT_COUNT =3D 1 + sys.exit(CheckGitCommits(GIT_REFERENCE, COMMIT_COUNT).ok) --=20 2.21.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#51789): https://edk2.groups.io/g/devel/message/51789 Mute This Topic: https://groups.io/mt/67004028/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-