unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* New Git hooks for checking file names in commit messages
@ 2023-04-21  4:55 Jim Porter
  2023-04-21 12:05 ` John Yates
  2023-04-21 13:57 ` Alan Mackenzie
  0 siblings, 2 replies; 34+ messages in thread
From: Jim Porter @ 2023-04-21  4:55 UTC (permalink / raw)
  To: emacs-devel

(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.



^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2023-04-23 19:24 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-21  4:55 New Git hooks for checking file names in commit messages Jim Porter
2023-04-21 12:05 ` John Yates
2023-04-21 16:44   ` Jim Porter
2023-04-21 17:44     ` Jim Porter
2023-04-22  6:11       ` Eli Zaretskii
2023-04-22  6:59         ` Jim Porter
2023-04-22  7:51           ` Eli Zaretskii
2023-04-22 19:44             ` Jim Porter
2023-04-22 23:21               ` John Yates
2023-04-21 13:57 ` Alan Mackenzie
2023-04-21 15:05   ` Eli Zaretskii
2023-04-21 15:38     ` Arsen Arsenović
2023-04-21 15:50       ` Eli Zaretskii
2023-04-21 16:20         ` Arsen Arsenović
2023-04-21 17:44           ` Eli Zaretskii
2023-04-21 17:50             ` Arsen Arsenović
2023-04-22  6:16               ` Eli Zaretskii
2023-04-21 18:25             ` Andreas Schwab
2023-04-21 19:03         ` Björn Bidar
2023-04-21 19:53           ` Jim Porter
2023-04-22  7:03           ` Eli Zaretskii
2023-04-22 19:52             ` Jim Porter
2023-04-23  6:11               ` Eli Zaretskii
2023-04-23  7:07                 ` Jim Porter
2023-04-23  7:37                   ` Eli Zaretskii
2023-04-23 19:15                     ` Jim Porter
2023-04-23 19:24                       ` Eli Zaretskii
2023-04-23  7:19                 ` Jim Porter
2023-04-23  7:39                   ` Eli Zaretskii
2023-04-23  9:51                     ` Björn Bidar
2023-04-22 23:55     ` Dmitry Gutov
2023-04-23  5:36       ` Eli Zaretskii
2023-04-23  9:47       ` Björn Bidar
2023-04-21 16:39   ` Jim Porter

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).