Subscribe processes a subscribe message, resolving paths to git repo roots and adding new repos to the watch set. Returns true if any new repo roots were added.
(paths []string)
| 109 | // roots and adding new repos to the watch set. Returns true if any new |
| 110 | // repo roots were added. |
| 111 | func (h *Handler) Subscribe(paths []string) bool { |
| 112 | if !h.gitAvailable() { |
| 113 | return false |
| 114 | } |
| 115 | |
| 116 | h.mu.Lock() |
| 117 | defer h.mu.Unlock() |
| 118 | |
| 119 | added := false |
| 120 | for _, p := range paths { |
| 121 | if !filepath.IsAbs(p) { |
| 122 | continue |
| 123 | } |
| 124 | p = filepath.Clean(p) |
| 125 | |
| 126 | root, err := findRepoRoot(h.gitBin, p) |
| 127 | if err != nil { |
| 128 | // Not a git path — silently ignore. |
| 129 | continue |
| 130 | } |
| 131 | if _, ok := h.repoRoots[root]; ok { |
| 132 | continue |
| 133 | } |
| 134 | h.repoRoots[root] = struct{}{} |
| 135 | added = true |
| 136 | } |
| 137 | return added |
| 138 | } |
| 139 | |
| 140 | // RequestScan pokes the scan trigger so the run loop performs a scan. |
| 141 | func (h *Handler) RequestScan() { |