From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Mistakes in commit log messages Date: Tue, 11 Apr 2023 09:02:05 +0300 Message-ID: <838rezardu.fsf@gnu.org> References: <835ya5m4p0.fsf@gnu.org> <83v8i4arzt.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3419"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Apr 11 08:02:28 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 1pm75H-0000dj-SR for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Apr 2023 08:02:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pm74S-0004z3-23; Tue, 11 Apr 2023 02:01:36 -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 1pm74H-0004yb-Df for emacs-devel@gnu.org; Tue, 11 Apr 2023 02:01:25 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pm74F-0003n8-GQ; Tue, 11 Apr 2023 02:01:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=Zf88BsaREFzqRvSX7nl0wvf6OKwV1G9NPhSnvxZLVOI=; b=FpeOlK5soa681yx+HDKx Heqp1YHSfvfF4tiFN+D2dI5qkztJgXzaWOBl/htf2aQr4hWLp3M/tZKZw28uBvj/grDbHrcKTjhOZ RVTh1q2Ll8Sb8QLTyik7juVPk5NGeVnIAWDU86Qm4FyYN0w72Ak8M9gRBhpLiiekjRq6L5XbGXtz6 0tXx+liwWcCecGZzMlYTEbmVVH1/QyKt3dHhYm+YcOz3d0S1eVKEbpfU24JY2y9+/U0pugvkB0Ztc sXrgeO4cVOV9KCQY49x4p0I7v2odlglWrq+C/bhPlNkGPnqT4DBG8saIIvLqFnhazREDT7FZ8Zoaf TnFi7q7wlLqO3g==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pm74E-0002Uo-Kj; Tue, 11 Apr 2023 02:01:22 -0400 In-Reply-To: (message from Jim Porter on Mon, 10 Apr 2023 14:52:15 -0700) 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:305231 Archived-At: > From: Jim Porter > Date: Mon, 10 Apr 2023 14:52:15 -0700 > Cc: Alan Mackenzie , philipk@posteo.net, luangruo@yahoo.com > > > On Mon, Apr 10, 2023 at 10:18 AM Jim Porter wrote: > > I looked into doing this, and I think it'd be possible to extend the > > existing commit-msg hook (in build-aux/git-hooks) to do this, at least > > using gawk. I don't really know awk though, so I'm sure my solution > > would be clumsy and probably gawk-specific. I wonder if we could make > > the hooks use Emacs Lisp... > > If someone could figure out how to disable this code on non-gawk awks, > I think the attached diff should do the trick. Any thoughts? I think a solution that doesn't use Gawk-specific features would be preferable, since no one said the mistakes are private only to users of GNU/Linux and MS-Windows, where Gawk is basically the only Awk. For the other readers of emacs-devel: this came from a private email I wrote to several of our active contributors telling them that their commit log messages included a substantial number of mistakes in file names mentioned in the log message. The admin/authors.el program discovered those mistakes while trying to generate attributions for who did what in Emacs (the etc/AUTHORS file). Someone suggested to augment our commit hooks to avoid such mistakes, at least those of them that can be easily detected by a simple script. The script suggested by Jim is below: > diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg > index d0578bcfb46..cdc99f4b399 100755 > --- a/build-aux/git-hooks/commit-msg > +++ b/build-aux/git-hooks/commit-msg > @@ -45,6 +45,7 @@ at_sign= > > # Check the log entry. > exec $awk -v at_sign="$at_sign" -v cent_sign="$cent_sign" -v file="$1" ' > + @load "filefuncs" > BEGIN { > # These regular expressions assume traditional Unix unibyte behavior. > # They are needed for old or broken versions of awk, e.g., > @@ -129,6 +130,18 @@ at_sign= > status = 1 > } > > + /^* / { > + # Check that any filenames mentioned in the commit message > + # actually exist. Currently, this only prints a warning to > + # prevent potential issues with false positives. > + if(match($2, "[^:/][^:]*")) { > + FILE = substr($2, RSTART, RLENGTH) > + if(stat(FILE, type) < 0) { > + printf("Warning: file '\''%s'\'' in commit message not found\n", FILE) > + } > + } > + } > + > $0 ~ unsafe_gnu_url { > needs_rewriting = 1 > }