Thread (581 messages) flat view 581 messages, 16 authors, 2021-10-12

Re: [PATCH v4 3/9] hook: add list command

From: Emily Shaffer <hidden>
Date: 2020-09-11 16:51:38

On Fri, Sep 11, 2020 at 02:27:42PM +0100, Phillip Wood wrote:
Hi Emily
quoted
+Global config
+----
+  [hook "post-commit"]
+    command = "linter"
+    command = "~/typocheck.sh"
+
+  [hookcmd "linter"]
+    command = "/bin/linter --c"
+----
+
+Local config
+----
+  [hook "prepare-commit-msg"]
+    command = "linter"
+  [hook "post-commit"]
+    command = "python ~/run-test-suite.py"
+----
I think it would be helpful to have a couple of lines explaining what the
example configuration sets up
Sure.
quoted
+COMMANDS
+--------
+
+list <hook-name>::
+
+List the hooks which have been configured for <hook-name>. Hooks appear
+in the order they should be run, and note the config scope where the relevant
+`hook.<hook-name>.command` was specified, not the `hookcmd` (if applicable).
Thanks for clarifying that it is the origin of the hook.<hook-name>.command
that is printed. An example of the output of the config above would be
useful I think.
Oh, that's a good idea - you're absolutely right. I'll do that.
quoted
+/*
+ * NEEDSWORK: a stateful hook_head means we can't run two hook events in the
+ * background at the same time - which might be ok, or might not.
+ *
+ * Maybe it's better to cache a list head per hookname, since we can probably
+ * guess that the hook list won't change during a user-initiated operation. For
+ * now, within list_hooks, call clear_hook_list() at the outset.
+ */
+static LIST_HEAD(hook_head);
I can see a cache might be useful for the sequencer which needs to run the
prepare-msg hook for each commit (it should probably not be running the
post-commit hook but does at the moment) and for am which runs some hooks
for each patch but until then I'm not sure why we need a global variable
here, can't we just declare `hook_head` in `list_hook()`?
Yeah, I agree. I'll make that change with the next reroll.

Thanks for reading.
 - Emily
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help