NewHandler creates a new git watch handler.
(logger slog.Logger, opts ...Option)
| 78 | |
| 79 | // NewHandler creates a new git watch handler. |
| 80 | func NewHandler(logger slog.Logger, opts ...Option) *Handler { |
| 81 | h := &Handler{ |
| 82 | logger: logger, |
| 83 | clock: quartz.NewReal(), |
| 84 | gitBin: "git", |
| 85 | repoRoots: make(map[string]struct{}), |
| 86 | lastSnapshots: make(map[string]repoSnapshot), |
| 87 | scanTrigger: make(chan struct{}, 1), |
| 88 | } |
| 89 | for _, opt := range opts { |
| 90 | opt(h) |
| 91 | } |
| 92 | |
| 93 | // Check if git is available. |
| 94 | if _, err := exec.LookPath(h.gitBin); err != nil { |
| 95 | h.logger.Warn(context.Background(), "git binary not found, git scanning disabled") |
| 96 | } |
| 97 | |
| 98 | return h |
| 99 | } |
| 100 | |
| 101 | // gitAvailable returns true if the configured git binary can be found |
| 102 | // in PATH. |
no outgoing calls