Repository navigation
Every git the library runs takes a context: a hanging git can be stopped, and a stopped run says so - #86
Merged
Conversation
Every `git` subprocess was started with `exec.Command`: nothing could stop one. A program using the library on a range it was handed had no way out of a `git` that hangs, and the command's own shutdown context went nowhere. The context is threaded through: `git.Commits`, `Check`, `Show`, `LogUntil`, `LogCommit`, `FetchHeadCommit` and `HeadCommit` take it first, as do `validate.NewRunner`, `Runner.Run`, `validate.Commit` and a rule's `Run`, since a rule may run git itself (dangling-whitespace does). The command passes the context its shutdown gives it. git is started with `exec.CommandContext`, which kills it when the context ends. A killed git reports "signal: killed", not why, so every run of git goes through `ended`: when the context is done, the error is the context's, with git's own after it. A range check that was stopped says so, and not that the range does not resolve. `Run` stops among the commits too. It looks at the context before each commit and after it, and returns the context's error: `Results` holds the commits validated whole, and nothing of the one a rule was stopped at, whose rules return the stop and not a judgment. Without that, a run stopped at its first commit returned nil with every later commit recorded as failing validation. This breaks every caller of the two packages, as the Runner's change before it did; nothing is tagged between them. Tests: a stand-in git that never ends (the test binary, run as git) is killed when the context is cancelled while it runs, the call returning `context.Canceled` together with git's end by a kill; under a done context no git is started and each of the seven functions returns the context's error; `Run` hands its context to every rule and, under a done one, lists nothing and runs no rule; a context that ends in a rule or between two commits stops the run there, with the earlier commits' results and no other; `NewRunner` stops looking for a commit when its context ends while git runs. Broken on purpose, each alone: git not run under the context; a killed git keeping its own error; the context's error replacing git's; `Run`, `Commit` or `NewRunner` handing on another context: each fails. noctx leaves the lint backlog for git/commits.go, and the five debug logs that now have a context use it. For #37. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: closer-claudio <claudio@farcloser.world>
closer-claudio
enabled auto-merge
November 15, 2026 20:43
Author
|
Reviewed at 2a06c0d |
apostasie
approved these changes
Nov 15, 2026
This was referenced Nov 16, 2026
closer-claudio
added a commit
that referenced
this pull request
Nov 16, 2026
The table of what upstream does not have stops at the shallow-clone refusal. Three later changes a user of the command can see have no row: QUIET in the environment no longer quiets it (#81), errors say what was being done (#83), and a run can be stopped (#86). Upstream's main is still the commit forked from: the comparison of a8d4555 with main, asked of GitHub today, is zero commits ahead. The "Reviewed through" line takes today's date. For #50. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: closer-claudio <claudio@farcloser.world>
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.
🎯 Why
Every
gitsubprocess the library runs was started withexec.Command: nothing could stop one. A program using the library on a range it was handed had no way out of agitthat hangs, and the command's own shutdown context went nowhere.For #37 (its
noctxfindings).🛠️ What
The breaking change, for a caller of the two packages: a context comes first in
git.Commits,Check,Show,LogUntil,LogCommit,FetchHeadCommitandHeadCommit, invalidate.NewRunner,Runner.Runandvalidate.Commit, and in a rule'sRun(a rule may run git itself; dangling-whitespace does).exec.CommandContext, which kills it when the context ends. A killed git reports "signal: killed", not why, so when the context is done the error is the context's, with git's own after it. A range check that was stopped says so, and not that the range does not resolve.Runner.Runstops among the commits too: it looks at the context before each commit and after it, and returns the context's error.Resultsholds the commits validated whole, and nothing of the one a rule was stopped at. Without that, a run stopped at its first commit returned nil with every later commit recorded as failing validation..lint-go.yaml:noctxleaves the backlog forgit/commits.go.🧪 How
A context reaches every git the library runsjust lintandjust testpass on macOS arm64 (62 tests).context.Canceledtogether with git's end by a kill; under a done context no git is started and each of the seven functions returns the context's error.Runhands its context to every rule; under a done one it lists nothing and runs no rule; a context that ends in a rule or between two commits stops the run there, with the earlier commits' results and no other (TestRunStopsAmongTheCommits, three rows over five commits).Run,CommitorNewRunnerhanding on another context; the check before a commit removed; the check after a commit removed. Each fails.📝 Notes