repo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package repo handles DVC repository discovery and well-known paths.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not a DVC repository (no .dvc directory found)")

ErrNotFound is returned when no .dvc directory is found.

Functions

func GitAdd

func GitAdd(dir string, paths ...string) error

GitAdd stages the given paths in the git repo at dir, mirroring what DVC does after init.

func InGitWorkTree

func InGitWorkTree(dir string) bool

InGitWorkTree reports whether dir is inside a git work tree. It shells out to git, which is only consulted in scm mode (the standalone --no-scm path never calls this).

func InitRepo

func InitRepo(root string, mode InitMode) (*Repo, InitOutcome, error)

InitRepo creates a .dvc repository structure byte-compatible with what `dvc init` (ModeSCM) or `dvc init --no-scm` (ModeNoSCM) produces. It does not create the cache directory (DVC creates it lazily on the first add). It is safe: if the directory already has a repo, or sits inside one, it reports the outcome without modifying anything.

func SetRemote

func SetRemote(path string, r Remote, makeDefault bool) error

SetRemote adds or updates a remote in .dvc/config, optionally as the default.

Types

type Config

type Config struct {
	CoreRemote string
	CacheType  string
	Remotes    map[string]Remote
}

Config is the parsed .dvc/config.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig parses .dvc/config. A missing file yields defaults.

type InitMode

type InitMode int

InitMode selects the initialization flavor.

const (
	ModeSCM   InitMode = iota // git-tracked repo (empty config + .dvc/.gitignore)
	ModeNoSCM                 // standalone repo (config has no_scm = True)
)

type InitOutcome

type InitOutcome int

InitOutcome reports what InitRepo did.

const (
	Created            InitOutcome = iota // structure created
	AlreadyInitialized                    // .dvc/ already exists in root
	InsideExistingRepo                    // an ancestor already has a .dvc/
)

type Remote

type Remote struct {
	Name            string
	URL             string
	EndpointURL     string
	Region          string
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
	Profile         string
}

Remote is a configured storage remote (S3-compatible in the MVP).

type Repo

type Repo struct {
	Root   string // directory containing .dvc
	DvcDir string // the .dvc directory
}

Repo points at a discovered DVC repository.

func Find

func Find(start string) (*Repo, error)

Find walks up from start until it locates a .dvc directory.

func Init

func Init(root string) (*Repo, error)

Init creates a standalone (no-scm) repository. Convenience wrapper kept for callers/tests that just need a working repo.

func (*Repo) CacheDir

func (r *Repo) CacheDir() string

func (*Repo) ConfigPath

func (r *Repo) ConfigPath() string

func (*Repo) LockPath

func (r *Repo) LockPath() string

func (*Repo) StatePath

func (r *Repo) StatePath() string

func (*Repo) TmpDir

func (r *Repo) TmpDir() string

Jump to

Keyboard shortcuts

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