fix: bound stalled git commands with actionable diagnostics - #86
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
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.
Testing
IsHeadMergedIntoRefretains its special exit-code-1 meaning for an unmerged head while using the same bounded command execution path for hangs and other failures.What Changed
Centralize subprocess construction in
internal/git/git.goaroundexec.CommandContextand apply a conservative default deadline to every git command, including the merge-ancestor path that currently bypassesrunGit; this protects fetch, worktree creation, checkout/reset/clean, and the repository-discovery commands without changing every caller. Preserve existing exit-code handling for commands that finish normally, but distinguish deadline expiry and return an error that names the stalled git operation and working directory, with concise hints for stale.git/index.lock, credentials, and network checks. Keep the timeout policy local to the git adapter rather than introducing a broad pool API or a helper used only by tests; the issue's immediate correctness requirement is a bounded failure, while the centralized duration remains a single production setting that can be exposed through configuration separately if maintainers want that additional surface.Why
treehouse getandtreehouse returnultimately launch git subprocesses throughinternal/git, but those commands have no deadline. A stale repository lock, blocked credential helper, or stalled network operation can therefore leave the CLI indefinitely at its setup banner. The maintainer confirmed the gap and invited a PR, and the issue has no assignee, competing PR, or closed-unmerged prior attempt.Fixes #64