From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.devel Subject: Re: Mistakes in commit log messages Date: Wed, 12 Apr 2023 23:18:37 -0700 Message-ID: <48d4dffa-cfa8-7949-3043-a1efa937902d@gmail.com> References: <835ya5m4p0.fsf@gnu.org> <83v8i4arzt.fsf@gnu.org> <838rezardu.fsf@gnu.org> <319d616d-9230-0a82-331f-0f57488e4c80@gmail.com> <834jpm9s1g.fsf@gnu.org> <83v8i28b3j.fsf@gnu.org> <693285d2-e50b-289d-4f3e-ddd817ddc75b@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------kRJEPrxqOXqoxZOJx2HNhLNa" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20073"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 13 08:19:44 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pmqJ5-00051C-S4 for ged-emacs-devel@m.gmane-mx.org; Thu, 13 Apr 2023 08:19:43 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmqIH-0005D8-BD; Thu, 13 Apr 2023 02:18:55 -0400 Original-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 1pmqI9-0005B6-Ju for emacs-devel@gnu.org; Thu, 13 Apr 2023 02:18:46 -0400 Original-Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmqI7-0003iY-5r; Thu, 13 Apr 2023 02:18:45 -0400 Original-Received: by mail-pl1-x633.google.com with SMTP id ke16so13920754plb.6; Wed, 12 Apr 2023 23:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681366720; x=1683958720; h=in-reply-to:references:cc:to:from:content-language:subject :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=3iDh9Rj78DfkLljd8zSQ455lcJM8UKWU7hwqscmQzfU=; b=E296QLYkvlShAri2fGMdCkvdVZVyKzXyV2u5SsbSBpUmkHD21rwKNxyltonQzluenK k0GmMgXEjTq3bUkIq6P1UoyEiys6+fc1zlsvNZgEdUE5IJH3Z6+0brQHDuw6TvZlvLXL A/QrReBJmv826QppgWA6PSCwoF+gG6mHsrYnLNju/VlXAdN6UTbldnOopito96uhxCj1 CiZPCNCtpT42Ihk2EVV0sv6Z1PZVSQE475q2FVsmVY31iACCd/oDOQy+NRHBnULJLMAd QmjAl1ieUc/OSVVDg4Ff04HpDtda/RjZjm7FxtuvZVNpv0rKtyZzsWzHi8U7mjRAznZv gvqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681366720; x=1683958720; h=in-reply-to:references:cc:to:from:content-language:subject :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=3iDh9Rj78DfkLljd8zSQ455lcJM8UKWU7hwqscmQzfU=; b=G0gFRsmGoDvkBVit4oXsTzR5lLLEXWVA0twVfu3D6AeEOBJsSi6du+JATN9lI9cFaF I/2m8SJa3xHycV3mux3uSVR+6XZewP/G8a/ly4VcnMwv1HmeVconKGKKFV7xE9LBanUJ wUFj2tX1dFRL0RFE4ijnT8RyOyKMohiXxjaj6qQz1KVk42sjJuD1oO5k/NuMwgsWlmoZ eeJKwV7GYeIP20W9r6TNqhczzmxIfN/nY7THllqrwOknc4Pr0rQuNL7f4MwL/UayTIuO c7n+6NvqJyj1CFwNTONsRFJ4t8+tZE1kBnTaFaFO4KT/h5Np3/m3SDdoOJXFwWJ6vQVa EReg== X-Gm-Message-State: AAQBX9e4ntvpuTNwgVQrsntSTrDFsl4JEhsxNDmPqDmymZnm527iiP8O 5aRdWwziZjb7Dtv4x7gm4LCw6qg3MXzXww== X-Google-Smtp-Source: AKy350akCh1G6GU1BD1LX9o85h76ydcfFmw8yUZBrMHt0ewbPea7YVxdxyhdkPe8xJ+tP3D0nHPL8w== X-Received: by 2002:a17:90a:3006:b0:240:b3ae:d890 with SMTP id g6-20020a17090a300600b00240b3aed890mr874633pjb.19.1681366719518; Wed, 12 Apr 2023 23:18:39 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id t3-20020a170902b20300b001a66fd54dd4sm618358plr.258.2023.04.12.23.18.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Apr 2023 23:18:38 -0700 (PDT) Content-Language: en-US In-Reply-To: <693285d2-e50b-289d-4f3e-ddd817ddc75b@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=jporterbugs@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:305279 Archived-At: This is a multi-part message in MIME format. --------------kRJEPrxqOXqoxZOJx2HNhLNa Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/11/2023 5:20 PM, Jim Porter wrote: > If we did something like this, I think both post-commit and pre-push > hooks would be useful. The former gives committers immediate feedback on > their commit message (if they read the output), while the latter is what > ensures that the upstream commit messages are properly-formatted. Attached is a mostly-working pair of hooks (post-commit and pre-push) to check this. There's still a bit more work to do though: 1. Clean up the output a bit 2. Make it work on non-gawk awks Both of those should be pretty easy though. Here's an example of the error if you try to push: -------------------------------------------------- In commit 89f2dbb773: My commit message File lisp/bad.el listed in commit message, but not in diff Push aborted; please see the file 'CONTRIBUTE' error: failed to push some refs to 'jporter@git.sv.gnu.org:/srv/git/emacs.git' -------------------------------------------------- For the post-commit hook, we just pass the current commit SHA to our awk script, which checks that SHA to make sure its commit message is correct. For the pre-push hook, we need to compare the local ref that we're pushing to the remote ref, and then check every commit between the two (the Git documentation explains a bit about how the hook works[1]). Assuming the general strategy looks ok, I'll finish this up and add more documentation for what's going on. [1] https://git-scm.com/docs/githooks#_pre_push --------------kRJEPrxqOXqoxZOJx2HNhLNa Content-Type: text/plain; charset=UTF-8; name="0001-WIP-Add-Git-hooks-to-check-filenames-listed-in-the-c.patch" Content-Disposition: attachment; filename*0="0001-WIP-Add-Git-hooks-to-check-filenames-listed-in-the-c.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSBhYzBlMmJiY2M5OWIwN2VhNTE4NTA0MWY1YTA2NmMzNmNjMWU0MmFjIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBKaW0gUG9ydGVyIDxqcG9ydGVyYn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YXRjaCgkMiwgIlteOi9dW146XSoiKSkgeworICAgICAgZmlsZW5hbWUgPSBzdWJz dHIoJDIsIFJTVEFSVCwgUkxFTkdUSCkKKyAgICAgIGlmICghIChmaWxlbmFtZSBpbiBjaGFu Z2VzKSkgeworICAgICAgICBpZiAoZ29vZCkgeworICAgICAgICAgIHByaW50ZigiSW4gY29t bWl0ICVzOiAlc1xuIiwgc3Vic3RyKGNvbW1pdF9zaGEsIDEsIDEwKSwgbXNnKQorICAgICAg ICB9CisgICAgICAgIHByaW50ZigiICBGaWxlICVzIGxpc3RlZCBpbiBjb21taXQgbWVzc2Fn ZSwgYnV0IG5vdCBpbiBkaWZmXG4iLAorICAgICAgICAgICAgICAgZmlsZW5hbWUpCisgICAg ICAgIGdvb2QgPSAwCisgICAgICB9CisgICAgfQorICB9CisKKyAgcmV0dXJuIGdvb2QKK30K ZGlmZiAtLWdpdCBhL2J1aWxkLWF1eC9naXQtaG9va3MvcG9zdC1jb21taXQgYi9idWlsZC1h dXgvZ2l0LWhvb2tzL3Bvc3QtY29tbWl0Cm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAw MDAwMDAwMDAwLi4zNWM5MDJkODI3MAotLS0gL2Rldi9udWxsCisrKyBiL2J1aWxkLWF1eC9n aXQtaG9va3MvcG9zdC1jb21taXQKQEAgLTAsMCArMSwxOSBAQAorIyEvYmluL3NoCisKK2dp dCByZXYtcGFyc2UgSEVBRCB8IGF3ayAnCisgICMgRklYTUU6IERvIHRoaXMgYSBQT1NJWC1j b21wYXRpYmxlIHdheS4KKyAgQGluY2x1ZGUgIi5naXQvaG9va3MvY29tbWl0LW1zZy1maWxl cy5hd2siCisKKyAgL15bYS16MC05XXs0MH0kLyB7CisgICAgaWYgKCEgY2hlY2tfY29tbWl0 X21zZ19maWxlcygkMCkpIHsKKyAgICAgIHN0YXR1cyA9IDEKKyAgICB9CisgIH0KKworICBF TkQgeworICAgIGlmIChzdGF0dXMgIT0gMCkgeworICAgICAgcH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SAiIG5ld3JlZiAifiIgYmFjaykgfCBnZXRsaW5lIG9sZHJlZgorICAgICAgaWYgKCEob2xk cmVmIH4gL15bYS16MC05XXs0MH0kLykpIHsKKyAgICAgICAgIyBUaGUgU0hBIGlzIG1pc2Zv cm1hdHRlZD8hCisgICAgICAgIGV4aXQgMgorICAgICAgfQorICAgIH0gZWxzZSBpZiAoJDQg fiAvXlthLXowLTldezQwfSQvKSAgeworICAgICAgb2xkcmVmID0gJDQKKyAgICB9IGVsc2Ug eworICAgICAgIyBUaGUgcmVtb3RlIFNIQSBpcyBtaXNmb3JtYXR0ZWQ/IQorICAgICAgZXhp dCAyCisgICAgfQorCisgICAgIyBJdGVyYXRlIG92ZXIgZXZlcnkgU0hBIGFmdGVyIG9sZHJl ZiwgdXAgdG8gKGFuZCBpbmNsdWRpbmcpIG5ld3JlZi4KKyAgICB3aGlsZSAoKCgiZ2l0IHJl di1saXN0IC0tcmV2ZXJzZSAiIG9sZHJlZiAiLi4iIG5ld3JlZikgfCBnZXRsaW5lKSA+IDAp IHsKKyAgICAgIGlmICghIGNoZWNrX2NvbW1pdF9tc2dfZmlsZXMoJDApKSB7CisgICAgICAg IHN0YXR1cyA9IDEKKyAgICAgIH0KKyAgICB9CisgIH0KKworICBFTkQgeworICAgIGlmIChz dGF0dXMgIT0gMCkgeworICAgICAgcHJpbnQgIlB1c2ggYWJvcnRlZDsgcGxlYXNlIHNlZSB0 aGUgZmlsZSAnXCcnQ09OVFJJQlVURSdcJyciCisgICAgfQorICAgIGV4aXQgc3RhdHVzCisg IH0KKycKLS0gCjIuMjUuMQoK --------------kRJEPrxqOXqoxZOJx2HNhLNa--