MCPcopy Index your code
hub / github.com/dagger/dagger / gitModuleSource

Method gitModuleSource

core/schema/modulesource.go:574–783  ·  view source on GitHub ↗

nolint:gocyclo

(
	ctx context.Context,
	query dagql.ObjectResult[*core.Query],
	source string,
	parsed *core.ParsedGitRefString,
	refPin string,
	// whether to search up the directory tree for a dagger.json file
	doFindUp bool,
)

Source from the content-addressed store, hash-verified

572
573//nolint:gocyclo
574func (s *moduleSourceSchema) gitModuleSource(
575 ctx context.Context,
576 query dagql.ObjectResult[*core.Query],
577 source string,
578 parsed *core.ParsedGitRefString,
579 refPin string,
580 // whether to search up the directory tree for a dagger.json file
581 doFindUp bool,
582) (inst dagql.Result[*core.ModuleSource], err error) {
583 dag, err := query.Self().Server.Server(ctx)
584 if err != nil {
585 return inst, fmt.Errorf("failed to get dag server: %w", err)
586 }
587
588 var (
589 lockResolution lookupLockResolution
590 lookupLock *workspaceLookupLock
591 )
592 if refPin == "" {
593 lockMode, err := currentLookupLockMode(ctx)
594 if err != nil {
595 return inst, fmt.Errorf("%s lock mode: %w", lockModulesResolveOperation, err)
596 }
597 if lockMode != workspace.LockModeDisabled {
598 lookupLock, err = loadWorkspaceLookupLock(ctx, query.Self())
599 if err != nil {
600 return inst, fmt.Errorf("%s lockfile: %w", lockModulesResolveOperation, err)
601 }
602 if lookupLock == nil {
603 return inst, fmt.Errorf("experimental lockfile support is local-only")
604 }
605 lockResolution, err = resolveLookupFromLock(
606 lockMode,
607 lookupLock.lock,
608 lockModulesResolveOperation,
609 []any{source},
610 workspace.PolicyFloat,
611 )
612 if err != nil {
613 return inst, fmt.Errorf("%s lock resolution: %w", lockModulesResolveOperation, err)
614 }
615 refPin = lockResolution.Pin
616 }
617 }
618
619 gitRef, err := parsed.GitRef(ctx, dag, refPin)
620 if err != nil {
621 return inst, fmt.Errorf("failed to resolve git src: %w", err)
622 }
623
624 gitSrc := &core.ModuleSource{
625 ConfigExists: true, // we can't load uninitialized git modules, we'll error out later if it's not there
626 Kind: core.ModuleSourceKindGit,
627 Git: &core.GitModuleSource{
628 HTMLRepoURL: parsed.RepoRoot.Repo,
629 RepoRootPath: parsed.RepoRoot.Root,
630 Version: cmp.Or(gitRef.Self().Ref.ShortName(), gitRef.Self().Ref.SHA),
631 Commit: gitRef.Self().Ref.SHA,

Callers 2

moduleSourceMethod · 0.95
localModuleSourceMethod · 0.95

Calls 15

AsStringMethod · 0.95
initFromModConfigMethod · 0.95
loadBlueprintModuleMethod · 0.95
LoadUserDefaultsMethod · 0.95
StatFSExistsFunction · 0.92
StringTypeAlias · 0.92
NewLoaderFunction · 0.92
ResolveDepToSourceFunction · 0.92
NewResultForCurrentCallFunction · 0.92
currentLookupLockModeFunction · 0.85
loadWorkspaceLookupLockFunction · 0.85

Tested by

no test coverage detected