MCPcopy
hub / github.com/dagger/container-use / ListDescendantEnvironments

Method ListDescendantEnvironments

repository/repository.go:336–350  ·  view source on GitHub ↗

ListDescendantEnvironments returns environments that are descendants of the given commit. This filters environments to only those where the provided commit is an ancestor of the environment's current HEAD. Environments are sorted by most recently updated first.

(ctx context.Context, ancestorCommit string)

Source from the content-addressed store, hash-verified

334// This filters environments to only those where the provided commit is an ancestor
335// of the environment's current HEAD. Environments are sorted by most recently updated first.
336func (r *Repository) ListDescendantEnvironments(ctx context.Context, ancestorCommit string) ([]*environment.EnvironmentInfo, error) {
337 allEnvs, err := r.List(ctx)
338 if err != nil {
339 return nil, err
340 }
341
342 var filteredEnvs []*environment.EnvironmentInfo
343 for _, env := range allEnvs {
344 if r.isDescendantOfCommit(ctx, ancestorCommit, env.ID) {
345 filteredEnvs = append(filteredEnvs, env)
346 }
347 }
348
349 return filteredEnvs, nil
350}
351
352// isDescendantOfCommit checks if the environment is a descendant of the given commit
353// using git merge-base --is-ancestor which is the canonical way to check ancestry

Callers 2

TestEnvironmentSelectionFunction · 0.80
resolveEnvironmentIDFunction · 0.80

Calls 2

ListMethod · 0.95
isDescendantOfCommitMethod · 0.95

Tested by 1

TestEnvironmentSelectionFunction · 0.64