watcher

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package watcher monitors Git-internal state files for changes and notifies the TUI to refresh. Unlike naive approaches that recursively watch the entire working tree, this package watches only the ~5 files/directories inside .git that change on meaningful Git operations. This makes it safe for monorepos with 100k+ files where inotify/kqueue watches would be exhausted instantly.

Watched paths:

  • .git/index → staging changes (git add/reset)
  • .git/HEAD → branch switches, commits
  • .git/refs/heads → local branch updates
  • .git/refs/tags → tag creation/deletion
  • .git/refs/remotes → fetch/pull updates
  • .git/MERGE_HEAD → merge starts/ends
  • .git/REBASE_HEAD → rebase starts/ends
  • .git/FETCH_HEAD → fetch completions

For working-tree changes (file edits), we rely on the user pressing 'r' (refresh) or on the debounced index-change event that git add/status triggers, which is the same strategy Lazygit uses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watch

func Watch(_, gitDir string, debounce time.Duration) (<-chan Event, func(), error)

Watch monitors critical Git-internal paths at repoRoot for state changes and sends Event values on the returned channel. Rapid bursts are coalesced via the debounce window.

gitDir should be the absolute path to the .git directory (handles worktrees where .git is a file pointing elsewhere).

Call the returned stop function to tear down the watcher.

Types

type Event

type Event struct{}

Event is sent when the watcher detects relevant Git state changes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL