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: New Git hooks for checking file names in commit messages Date: Thu, 20 Apr 2023 21:55:15 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3618"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 21 06:56:12 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 1ppiod-0000lQ-TJ for ged-emacs-devel@m.gmane-mx.org; Fri, 21 Apr 2023 06:56:11 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppins-0003q1-CA; Fri, 21 Apr 2023 00:55:24 -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 1ppinr-0003pl-49 for emacs-devel@gnu.org; Fri, 21 Apr 2023 00:55:23 -0400 Original-Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ppino-0005O9-BX for emacs-devel@gnu.org; Fri, 21 Apr 2023 00:55:22 -0400 Original-Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-63b5465fc13so1572645b3a.3 for ; Thu, 20 Apr 2023 21:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682052918; x=1684644918; h=content-transfer-encoding:to:subject:from:content-language :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=b/mewug0BI89ADH6e3W1i9VC0do9O647Hv2imdQUAjg=; b=lfwgG40AaRNs3+MgAfRMcg0WuS/gGS1RZgopvmQTFKX2b4H18IeYWkYuN200ez9HLf bdS/uH8qmTwPLdgWAXZ3TbffSmPwgDnhUYBmjWWjFCJQxWKA+mHsiUr+5Geh+Y4NoxUC eiGI15N5UV+QcZ2WMkrkrjnaoI3c4iCa8HLyiGwEux581+X6pvydfW2mIspoYB3xdWlB ZvSrOlMZuHFmc6ONHpT1FRlKq5udpd3v6jHqu3JxVenx7jX3IqUJeJkWxffh2rAFsMcx G6ujnfnhLe84hBn7AtKCTFqTICeh0rOjt6/AOqgwhCrCrkDA94XkWnsq7lXQ+AV6ZU91 xSbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682052918; x=1684644918; h=content-transfer-encoding:to:subject:from:content-language :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=b/mewug0BI89ADH6e3W1i9VC0do9O647Hv2imdQUAjg=; b=A4IYHXo2HgLhLVYQp0WYPC4JlgxURcZYfU1wwc/vKL7c4SorUxiVxt/QD3qpT/M/c4 DOuC6kiBJThSWNIawJyOz2NoObCeWghEACFjUuLYekLsQydJPQ0S0AuTBdsYUTVNiLdN 8UTfFwbbunIlPfQOya1wyy6wnCmlOPyLjJqnM2aFlPrBypU3osv88TlpYYWM+DK2/uQL /Cq0DrxbSqq9xNZdk2GXlZYgdBVQ8mZoY3CVPG6fWLvr96ALPOyx7slnWBedWd1kfk0c LIoVJCKipI/VNFt8jZOJTW90d3SG6foZjZLpKDVvBNluQf+3WECtnYErU9NFPRGeD2aa X/fg== X-Gm-Message-State: AAQBX9cXDgs8oUt7SdYFD33OsQg0OOc57Os53i1PBXOrnftqVVjoVgmW GDPJNhmB2fPxh7Lld/+2gDfRKhUvmDEt8g== X-Google-Smtp-Source: AKy350b0P+ZzC8cESMX1+PrsHXLd+E5PvtYFoKc2NBVysjVW27IOyH+cJGqwwDnnNMIPrAZFSYUDkQ== X-Received: by 2002:aa7:88d1:0:b0:63b:8778:99f7 with SMTP id k17-20020aa788d1000000b0063b877899f7mr5140342pff.9.1682052917916; Thu, 20 Apr 2023 21:55:17 -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 r11-20020a62e40b000000b0063d375ca0cbsm2045939pfh.151.2023.04.20.21.55.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Apr 2023 21:55:17 -0700 (PDT) X-Mozilla-News-Host: news://news.gmane.io:119 Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=jporterbugs@gmail.com; helo=mail-pf1-x42b.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, T_SCC_BODY_TEXT_LINE=-0.01 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:305531 Archived-At: (For some background on this, see here: https://lists.gnu.org/archive/html/emacs-devel/2023-04/msg00274.html) I've just merged some new Git hooks that should help to identify errors in the list of file names in commit messages (see commit 4416262f59f). These ensure that any file name listed in the commit message is actually in the diff, so that it's harder to make a typo when writing the commit message. The hooks recognize files on lines starting with "*" or "; *". This also means that if you want to use a "*" for a bulleted list of sentences, you should do something to make it not look like a file entry. For example, " *" is ok. In addition to listing individual files, you can also list whole directories (e.g. if you added many files to a directory). However, you can't use wildcards in your file entries. (If people really want this, it's probably doable, but I think being explicit will help future maintainers if they ever need to grep the changelogs.) You can install these hooks via the autogen.sh script, as usual. There's one part that might be surprising, at least initially though: while this is a hook to check commit messages, it actually runs in the post-commit and pre-push phases. This is because we want to examine the full diff of the commit in order to compare against the file entries in the message.[1] As a result, you'll just get an advisory message when you make the commit (it's too late to error out), and the pre-push hook will prevent you from pushing a badly-formatted commit message upstream. I encourage everyone to test these hooks out and report back if you find any problems. I ran them locally on the last 5000 commits to master and manually verified that there are no false positives, but there could still be bugs. If you use a non-gawk awk, I especially encourage you to test them out. I did my best to only use POSIX awk features, but you never know... [1] It's hard to do this during the commit-msg hook since there's no cross-platform way I know of to handle amending commits properly.