refactor(git): consolidate ad-hoc git exec into internal/git#356
Merged
Conversation
Seven production call sites outside internal/git/ were spawning git via exec.Command directly, each with its own stdout/stderr wiring. This routes them through four new helpers in internal/git/exec.go so the package owns every git invocation in the codebase. The new surface: Output(dir, args...) (string, error) captures stdout; Run(dir, log, args...) sends both stdout and stderr to a single writer (the modal-log pattern); RunTTY(dir, args...) wires stdout/stderr straight to the user's terminal so shell redirects still work; RunCaptureStderr(dir, args...) mirrors stdout to the terminal while teeing stderr into a buffer the caller inspects for git's "use --force" hint. BranchExists(dir, branch) wraps the show-ref --verify pattern. Routed sites: internal/cli/worktree_ui.go (3 sites: branch-exists, worktree add, worktree remove), internal/cli/worktree_add.go (worktree add), internal/cli/worktree_remove.go (2 sites: worktree remove with force-detection plus the generic runGit), internal/ui/server.go (runGitOutput wraps Output). Each preserves the original cmd.Dir, stream wiring, and exit-code semantics. The only behaviour delta is the wrap text on errors (the helper picks the first non-flag arg for context, so "git remove: ..." reads as "git worktree: ..."), and no caller pattern-matches on that text.
Merged
geodro
added a commit
that referenced
this pull request
May 18, 2026
First beta of the 1.21.0 line. The headline is desktop notifications via Web Push (#353), with a per-category settings page polished alongside a dashboard health row (#354). The PHP-FPM image grows a real shell environment, zsh plus starship plus eza, bat, fzf, zoxide, isolated from the host (#358), then loses around 800 MB of build toolchain in a multi-stage split that drops the image from 1.36 GB to 535 MB without losing any of its 68 PHP modules (#364). A new on-demand commands feature surfaces one-shot framework actions across the dashboard, the lerd run CLI, the command palette, and four new MCP tools, all backed by a generalised Dropdown component that replaces every native select in the UI (#363). The site detail header gets a browser-style address bar with the favicon, TLS lock, LAN-share chip, and worktrees promoted from a dropdown to tabs (#365), an Env tab joins Overview, Tinker, and Dumps to show the project .env verbatim (#366), and the tray menu picks up Dump bridge and Notifications toggles that update live via a new KindDumpsStatus event (#373). Postgres grows 17 and 18 alternates alongside a new MySQL 9.7 LTS line, all gated by a canonical-version pin so flipping the yaml canonical no longer silently major-jumps existing installs (#361). Türkçe joins the dashboard languages (#355), a public_dir override lands in .lerd.yaml for projects with a non-standard document root (#370), every git invocation in the tree now flows through internal/git (#356), and worker-failure pushes are batched so a systemd cascade no longer fires six near-identical notifications back to back (#372). Plus the post-1.20.2 fix queue covers the worktree-manager button rendering on non-git sites (#357), TLS certs not refreshing when a secured site's domain set changed (#367), streamed worktree install and a wave of audit follow-ups (#368), and tinker swallowing bare-expression results when the dump bridge was on (#371).
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.
Seven production call sites outside internal/git/ were spawning git via exec.Command directly, each with its own stdout/stderr wiring. This routes them through four new helpers in internal/git/exec.go so the package owns every git invocation in the codebase.
The new surface: Output(dir, args...) (string, error) captures stdout; Run(dir, log, args...) sends both stdout and stderr to a single writer (the modal-log pattern); RunTTY(dir, args...) wires stdout/stderr straight to the user's terminal so shell redirects still work; RunCaptureStderr(dir, args...) mirrors stdout to the terminal while teeing stderr into a buffer the caller inspects for git's "use --force" hint. BranchExists(dir, branch) wraps the show-ref --verify pattern.
Routed sites: internal/cli/worktree_ui.go (3 sites: branch-exists, worktree add, worktree remove), internal/cli/worktree_add.go (worktree add), internal/cli/worktree_remove.go (2 sites: worktree remove with force-detection plus the generic runGit), internal/ui/server.go (runGitOutput wraps Output). Each preserves the original cmd.Dir, stream wiring, and exit-code semantics. The only behaviour delta is the wrap text on errors (the helper picks the first non-flag arg for context, so "git remove: ..." reads as "git worktree: ..."), and no caller pattern-matches on that text.