( ctx context.Context, dag *dagql.Server, )
| 1591 | } |
| 1592 | |
| 1593 | func (src *ModuleSource) LoadContextGit( |
| 1594 | ctx context.Context, |
| 1595 | dag *dagql.Server, |
| 1596 | ) (inst dagql.ObjectResult[*GitRepository], err error) { |
| 1597 | if src.Kind == ModuleSourceKindGit { |
| 1598 | // easy, we're running a git repo |
| 1599 | err := dag.Select(ctx, dag.Root(), &inst, |
| 1600 | dagql.Selector{ |
| 1601 | Field: "git", |
| 1602 | Args: []dagql.NamedInput{ |
| 1603 | {Name: "url", Value: dagql.String(src.Git.CloneRef)}, |
| 1604 | // NOTE: pin HEAD to the module's git commit and ref |
| 1605 | // this matches the behavior of calling a checked out local source module |
| 1606 | {Name: "commit", Value: dagql.String(src.Git.Commit)}, |
| 1607 | {Name: "ref", Value: dagql.String(src.Git.Ref)}, |
| 1608 | }, |
| 1609 | }, |
| 1610 | ) |
| 1611 | if err != nil { |
| 1612 | return inst, fmt.Errorf("failed to load contextual git repository: %w", err) |
| 1613 | } |
| 1614 | return inst, nil |
| 1615 | } |
| 1616 | |
| 1617 | // bit harder, this is actually a local directory |
| 1618 | dir, err := src.LoadContextDir(ctx, dag, "/", CopyFilter{ |
| 1619 | Gitignore: true, |
| 1620 | }) |
| 1621 | if err != nil { |
| 1622 | return inst, fmt.Errorf("failed to load contextual git: %w", err) |
| 1623 | } |
| 1624 | |
| 1625 | err = dag.Select(ctx, dir, &inst, |
| 1626 | dagql.Selector{ |
| 1627 | Field: "asGit", |
| 1628 | }, |
| 1629 | ) |
| 1630 | if err != nil { |
| 1631 | return inst, fmt.Errorf("failed to load contextual git repository: %w", err) |
| 1632 | } |
| 1633 | |
| 1634 | return inst, nil |
| 1635 | } |
| 1636 | |
| 1637 | type LocalModuleSource struct { |
| 1638 | ContextDirectoryPath string |
no test coverage detected