[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mistakes in commit log messages
From: |
Eli Zaretskii |
Subject: |
Re: Mistakes in commit log messages |
Date: |
Tue, 11 Apr 2023 09:02:05 +0300 |
> From: Jim Porter <jporterbugs@gmail.com>
> Date: Mon, 10 Apr 2023 14:52:15 -0700
> Cc: Alan Mackenzie <acm@muc.de>, philipk@posteo.net, luangruo@yahoo.com
>
>
> On Mon, Apr 10, 2023 at 10:18 AM Jim Porter <jporterbugs@gmail.com> 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
> }
- Re: Mistakes in commit log messages,
Eli Zaretskii <=
- Re: Mistakes in commit log messages, Alan Mackenzie, 2023/04/11
- Re: Mistakes in commit log messages, Jim Porter, 2023/04/11
- Re: Mistakes in commit log messages, Eli Zaretskii, 2023/04/11
- Re: Mistakes in commit log messages, Jim Porter, 2023/04/11
- Re: Mistakes in commit log messages, Eli Zaretskii, 2023/04/11
- Re: Mistakes in commit log messages, Jim Porter, 2023/04/11
- Re: Mistakes in commit log messages, Jim Porter, 2023/04/13