remote

package
v0.26.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Sources embed.FS

Sources embeds all non-test Go source files needed to reconstruct the remote package in an external module cache.

Functions

func DefaultNamespace

func DefaultNamespace(requirePath string) (string, error)

DefaultNamespace returns the default namespace for a remote require path.

func FindEntryPoint

func FindEntryPoint(cacheDir string, r *remotePath) (string, error)

FindEntryPoint locates the main Rugo file in a cloned module directory.

Resolution order (at root or subpath):

  1. <subpath>.rugo or <subpath>.rg at the repo root (flat-file subpath)
  2. <name>.rugo or <name>.rg in the subpath directory
  3. main.rugo or main.rg
  4. Exactly one Rugo source file

func IsRemoteRequire

func IsRemoteRequire(path string) bool

IsRemoteRequire returns true if the require path looks like a git URL (e.g. "github.com/user/repo"). Local paths like "helpers" or "lib/math" never have a dot in the first segment. Relative paths starting with "." or ".." are always local.

func SplitLockKey added in v0.13.1

func SplitLockKey(key string) (module, version string)

SplitLockKey splits a lock key ("module@version") into module and version.

func WriteLockFile

func WriteLockFile(path string, lf *LockFile) error

WriteLockFile writes the lock file to disk atomically. The content is written to a temp file first, then renamed over the target path to prevent corruption from concurrent writes.

Types

type LockEntry

type LockEntry struct {
	// Module is the repo path without version (e.g. "github.com/user/repo").
	Module string
	// Version is the requested version label (e.g. "v1.0.0", "main", "_default").
	Version string
	// SHA is the resolved full commit SHA.
	SHA string
}

LockEntry records the resolved commit SHA for a single remote module.

type LockFile

type LockFile struct {
	Entries []*LockEntry
	// contains filtered or unexported fields
}

LockFile holds all lock entries for a project.

func NewLockFile

func NewLockFile() *LockFile

NewLockFile creates an empty lock file.

func ReadLockFile

func ReadLockFile(path string) (*LockFile, error)

ReadLockFile reads a rugo.lock file. Returns an empty LockFile if the file does not exist.

func (*LockFile) Lookup

func (lf *LockFile) Lookup(module, version string) *LockEntry

Lookup finds the lock entry for a given module and version label. Returns nil if not found.

func (*LockFile) Prune added in v0.13.0

func (lf *LockFile) Prune(keep map[string]bool)

Prune removes entries whose keys are not in the keep set.

func (*LockFile) Set

func (lf *LockFile) Set(module, version, sha string)

Set adds or updates a lock entry.

type Resolver

type Resolver struct {
	// ModuleDir overrides the default module cache directory (~/.rugo/modules).
	ModuleDir string
	// Frozen errors if the lock file is stale or a new dependency is resolved.
	Frozen bool
	// ReadOnly prevents writing the lock file to disk.
	ReadOnly bool

	// SuppressHint prevents the "run rugo mod tidy" hint from being printed.
	SuppressHint bool
	// contains filtered or unexported fields
}

Resolver manages remote module fetching, caching, and lock file state.

func (*Resolver) FetchRepo

func (r *Resolver) FetchRepo(requirePath string) (string, error)

FetchRepo fetches a remote git repo and returns the cache directory. Unlike ResolveModule, it does not resolve an entry point.

func (*Resolver) InitLock

func (r *Resolver) InitLock(path string, lf *LockFile)

InitLock sets the lock file and path for the resolver. Used by the update command to inject a pre-loaded lock file.

func (*Resolver) InitLockFromDir

func (r *Resolver) InitLockFromDir(dir string) error

InitLockFromDir initializes the lock file from a rugo.lock in the given directory.

func (*Resolver) LockDirty

func (r *Resolver) LockDirty() bool

LockDirty returns whether the lock file was modified during resolution.

func (*Resolver) LockFile added in v0.13.0

func (r *Resolver) LockFile() *LockFile

LockFile returns the resolver's lock file.

func (*Resolver) ResolveModule

func (r *Resolver) ResolveModule(requirePath string) (string, error)

ResolveModule fetches a remote git module and returns the local path to its entry point Rugo file.

func (*Resolver) ResolveModuleOrDir added in v0.20.0

func (r *Resolver) ResolveModuleOrDir(requirePath string) (entryPoint, cacheDir string, err error)

ResolveModuleOrDir fetches a remote module and tries to find a Rugo entry point. If no entry point is found, returns the cache directory and a nil error with entryPoint set to "". This allows callers to fall back to Go module detection without a redundant fetch.

func (*Resolver) ResolvedKeys added in v0.13.0

func (r *Resolver) ResolvedKeys() map[string]bool

ResolvedKeys returns the set of lock keys resolved during this session.

func (*Resolver) UpdateEntry

func (r *Resolver) UpdateEntry(module string) error

UpdateEntry re-resolves a mutable dependency, ignoring the existing lock entry, and updates the lock file. If module is empty, all mutable entries are updated.

func (*Resolver) WriteLock added in v0.13.0

func (r *Resolver) WriteLock() error

WriteLock writes the lock file to disk unconditionally.

func (*Resolver) WriteLockIfDirty

func (r *Resolver) WriteLockIfDirty() error

WriteLockIfDirty writes the lock file to disk if it was modified.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL