MCPcopy Create free account
hub / github.com/delinoio/oss / worktree

Method worktree

cmds/async-commit-hook/internal/core/api.go:207–229  ·  view source on GitHub ↗
(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

205 return out
206}
207func (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}
230func (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}

Callers 4

ListBranchesMethod · 0.95
ListCommitsMethod · 0.95
GetChangesMethod · 0.95

Calls 5

ValidIDFunction · 0.85
EFunction · 0.85
DiscoverFunction · 0.85
ErrMethod · 0.80
RegisteredMethod · 0.80