| 205 | return out |
| 206 | } |
| 207 | func (a *API) worktree(ctx context.Context, id string) (string, error) { |
| 208 | if !ValidID(id) { |
| 209 | return "", E("invalid-worktree-id", "expected UUID v7", 2) |
| 210 | } |
| 211 | var path, repository string |
| 212 | e := a.s.Store.DB.QueryRowContext(ctx, "SELECT path,repository_id FROM worktrees WHERE id=?", id).Scan(&path, &repository) |
| 213 | if e == nil { |
| 214 | common, root, _, discoverErr := Discover(ctx, path) |
| 215 | if err := ctx.Err(); err != nil { |
| 216 | return "", err |
| 217 | } |
| 218 | if discoverErr == nil { |
| 219 | r, w, registeredErr := a.s.Store.Registered(common, root) |
| 220 | if registeredErr == nil && r.ID == repository && w.ID == id { |
| 221 | return path, nil |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | if err := ctx.Err(); err != nil { |
| 226 | return "", err |
| 227 | } |
| 228 | return "", E("worktree-unavailable", "registered worktree is unavailable", 2) |
| 229 | } |
| 230 | func (a *API) GetVersion(context.Context, *connect.Request[pb.GetVersionRequest]) (*connect.Response[pb.GetVersionResponse], error) { |
| 231 | return connect.NewResponse(&pb.GetVersionResponse{ApiVersion: 1, Version: Version}), nil |
| 232 | } |