Add opt-in stream_hook_output to show git hook output live (e.g. post-checkout migrations)#1962
Open
jcarlos7121 wants to merge 4 commits into
Open
Add opt-in stream_hook_output to show git hook output live (e.g. post-checkout migrations)#1962jcarlos7121 wants to merge 4 commits into
stream_hook_output to show git hook output live (e.g. post-checkout migrations)#1962jcarlos7121 wants to merge 4 commits into
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…hook exists Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's this?
A small, opt-in config flag —
stream_hook_output(defaultfalse) — that lets you actually watch a git hook's output stream into the Neogit console while it runs.My setup runs a
post-checkouthook (thehookupRuby gem) that runs DB migrations whenever I switch branches. Today that hook fires on every checkout but basically gets lost currently. The output is captured, but it gets swallowed silently.Why it doesn't already work
Turns out checkout is the only hook-bearing op that runs blocking (
branch.checkout→.call { await = true }). A blockingjobwaitfreezes redraws, and thevim.schedule'd "show console" timer can't fire mid-run — by the time it could, the result is already set and it bails, then auto-close finishes it off on success. So the console never gets a chance to stream. Meanwhilemerge/pushrun async and already stream their hook output via the existing 800ms timer — checkout was just the odd one out.What the flag does
When
stream_hook_output = true:branch.checkout/trackrun async instead of blocking — but only when apost-checkouthook actually exists — so the existing console machinery can stream the output live as it's produced.process.lua's timer force-shows the console for hook processes, so it works even if you've turnedauto_show_consoleoff.auto_close_console+ the existing hook-failure branch). So you watch it run, it tidies up after itself on success, and it sticks around so you can read the error if the hook fails.Default is
false, so this is zero behavior change unless you opt in.Scope / notes
rebase/bisectrun withlong = true(console suppressed), so they're intentionally out of scope.a.voidcoroutine, so the async path yields and resumes with theProcessResultexactly like before, and the runner falls back to blocking if it's ever called outside a coroutine.Tests
branch_checkout_await_spec.luaasserting checkout takes the async path only when the flag + apost-checkouthook are present (and blocks otherwise).config_spec.lua.styluaclean. Documented in README +doc/neogit.txt.