idv

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LOCAL points to CurrentCommitFile, the local commit containing staged updates not yet pushed
	// Or in case of checking out to a commit which is not the head of a branch, it points to HEAD
	LOCAL string = IDVFolder + "LOCAL"
	// HEAD points to the commit that local repo thinks is the head of the current branch remotely,
	// essentially the parent of LOCAL
	HEAD string = IDVFolder + "HEAD"
	// BRANCH points to the branch that local operates on
	BRANCH string = IDVFolder + "BRANCH"
	// TREE points to the .vtree that local thinks is the most recent version of .vtree
	TREE string = IDVFolder + "TREE"
)
View Source
const (
	// IDVFolder is the name of the folder these files are stored in (like .git)
	IDVFolder string = ".idv/"
)

useful folders folders for idv

Variables

This section is empty.

Functions

func AddFiles

func AddFiles(files []string) (adds, updates int, err error)

AddFiles stages new files to be added and existing files as Updates, expects a list of absolute file paths

func Apply

func Apply() (err error)

Apply sets up the necessary stuff at the Daemon using idv-config.yaml

func ApplyCommit

func ApplyCommit(name, description string) (err error)

ApplyCommit finalizes the currently staged changes and submits it to the daemon

func BranchFromCommit

func BranchFromCommit(branchName, commitHashOrName string, isHash bool) (err error)

BranchFromCommit branches off of the current commit onto a new branch

func Checkout

func Checkout(nameOrHash string, isCommit bool, isHash bool) (err error)

Checkout from the current branch onto another branch/commit

func Download

func Download(selector *regexp.Regexp) (err error)

Download data from this repository onto this local machine

func EnsureBRANCH

func EnsureBRANCH() error

EnsureBRANCH makes sure that BRANCH points to a file

func EnsureByPanic

func EnsureByPanic(ensurerFunc func() error, customMsg string)

EnsureByPanic takes one of the other Ensure functions and panics in case of an error rather than returning it

func EnsureChanges

func EnsureChanges() error

EnsureChanges errors if the current LOCAL commit has no staged changes

func EnsureConfig

func EnsureConfig() error

EnsureConfig checks whether there is a file called idv-config.yaml that can be parsed as config

func EnsureHEAD

func EnsureHEAD() error

EnsureHEAD makes sure that HEAD points to a file

func EnsureIDVRepo

func EnsureIDVRepo() error

EnsureIDVRepo makes sure that we are in an idv repository

func EnsureLOCAL

func EnsureLOCAL() error

EnsureLOCAL makes sure that LOCAL points to a file

func EnsureLOCALIsBranchHead

func EnsureLOCALIsBranchHead() error

EnsureLOCALIsBranchHead checks whether LOCAL is ahead of the current branch's branch.HEAD

func EnsureLatestCommit

func EnsureLatestCommit() error

EnsureLatestCommit makes sure that the current LOCAL is ahead of the BRANCH.HEAD

func EnsureNoBranchOffs

func EnsureNoBranchOffs() error

EnsureNoBranchOffs makes sure that there are no uncommitted branch and vtree files in .idv/local

func EnsureNoChanges

func EnsureNoChanges() error

EnsureNoChanges errors if there are uncommitted changes staged

func EnsureNoStaged

func EnsureNoStaged() error

EnsureNoStaged makes sure that there are no uncommitted staged changes in LOCAL

func EnsureSetup

func EnsureSetup() (err error)

EnsureSetup checks whether the repo is (correctly) setup by checking all the supposed symlinks

func EnsureTREE

func EnsureTREE() error

EnsureTREE makes sure that TREE points to a file

func Initialize

func Initialize(name, description string, backend storage.Backend) (err error)

Initialize instantiates a new data repo and makes appropriate .idv folder structure

func Inspect

func Inspect() (report string, err error)

Inspect returns the config file found in the same folder used for adding/committing and pusing data etc

func Ls

func Ls(selector *regexp.Regexp, fullPath bool) (report string, err error)

Ls lists all data in the current commit

func LsBranches

func LsBranches() (report string, err error)

LsBranches returns a string report specifying the list of currently known branches

func LsCommits

func LsCommits() (report string, err error)

LsCommits returns a string report specifying the list of commits on the current branch

func Pull

func Pull() (err error)

Pull gets the latest vtree from the daemon and attempts to resolve any conflicts arising locally from this

func RemoveFiles

func RemoveFiles(files []string, names []string, unstage bool) (removals, unstages int, err error)

RemoveFiles stages files for removal from the dataset files is expected to be a list of paths on this machine names can be random strings that are matched against names in the commit

func RemoveWithSelector

func RemoveWithSelector(selector *regexp.Regexp, unstage bool) (removals, unstages int, err error)

RemoveWithSelector removes files from data set and staging based on a regex. All files matching the selector are staged for removal, or unstaged in case a staged files

func Setup

func Setup() (err error)

Setup sets up the necessary stuff at the Daemon and locally links all necessary symlinks

func Status

func Status(fullPath, localPath bool) (report string, err error)

Status returns information about the currently staged files

func Unstage

func Unstage(selector *regexp.Regexp) (unstaged int, err error)

Unstage unstages adds/updates/removes of files that match the selector

Types

type Branch

type Branch struct {
	Name string `json:"name"`
	HEAD hash   `json:"head"`
	Hash hash   `json:"hash"`
}

Branch internally defines a data version commit file

func NewBranch

func NewBranch(name string) Branch

NewBranch creates and initializes a new branch

func (*Branch) ParseFromFile

func (b *Branch) ParseFromFile(filepath string) error

ParseFromFile tries to parse a .branch file

func (Branch) ToFilePath

func (b Branch) ToFilePath(local bool) string

ToFilePath returns a path to this commit being: .idv/{local, remote}/branchhash.extension local indicates which of the 2 folders to use

func (Branch) WriteToFolder

func (b Branch) WriteToFolder(folderPath string) error

WriteToFolder writes the branch to the specified folder. Name of file is and should be determined by the branch structure

type Commit

type Commit struct {
	Parent      hash       `json:"parent"`
	Branch      hash       `json:"branch"`
	Hash        hash       `json:"hash"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Files       []string   `json:"files"`
	Diff        diff       `json:"diff"`
	Deprecated  deprecated `json:"deprecated"`
}

Commit internally defines a data version commit file

func NewCommit

func NewCommit(parent Commit, branch hash, name string, desc string) Commit

NewCommit creates a bare new commit

func NewRootCommit

func NewRootCommit(branch hash) Commit

NewRootCommit creates a bare, empty root commit for initializing a new repo

func (Commit) FormatDiff

func (c Commit) FormatDiff(head string, tail string, ifEmpty string, delim string, fullPath bool, stagemap Stagemap) string

FormatDiff returns the list of changed files in the Diff as 1 long string interleaved with \n Usefull for display and filtering, head is prepended, tail is appended, isEmpty is used if no files are listed as follows: `headisEmptytail\n` else the strings produced are `OP file\n`, where OP is one of { U(pdated), R(emoved), A(dded)}

func (Commit) FormatFiles

func (c Commit) FormatFiles(selector *regexp.Regexp, head string, tail string, ifEmpty string, delim string, fullPath bool) string

FormatFiles returns the list of files as 1 long string interleaved with \n Usefull for display and filtering, head is prepended, tail is appended, isEmpty is used if no files are listed as follows: `headisEmptytail`

func (*Commit) ParseFromFile

func (c *Commit) ParseFromFile(filepath string) error

ParseFromFile tries to parse a .commit file

func (Commit) ToFilePath

func (c Commit) ToFilePath(local bool) string

ToFilePath returns a path to this commit being: .idv/{local, remote}/commithash.extension local indicates which of the 2 folders to use

func (Commit) WriteToFolder

func (c Commit) WriteToFolder(folderPath string) error

WriteToFolder writes the commit to the specified folder. Name of file is and should be determined by the commit structure

type Stagemap

type Stagemap map[string]string

Stagemap is a structure mapping idv filepaths to absolute filepaths on this machine

func (*Stagemap) ParseFromFile

func (s *Stagemap) ParseFromFile(filepath string) error

ParseFromFile tries to parse a idv config file

func (Stagemap) Verify

func (s Stagemap) Verify() (err error)

Verify ensures all file pointers in the staged file actually exist

func (Stagemap) WriteToFile

func (s Stagemap) WriteToFile() error

WriteToFile writes the config to the specified file.

type VTree

type VTree struct {
	Tree     commitTree `json:"tree"`
	Branches branchMap  `json:"branches"`
}

VTree holds a version tree for data versioning

func NewVTree

func NewVTree(root Commit, master Branch) VTree

NewVTree instantiates a new version tree and sets the root node

func (*VTree) ParseFromFile

func (v *VTree) ParseFromFile(filepath string) error

ParseFromFile tries to parse a history.vtree file

func (VTree) ToFilePath

func (v VTree) ToFilePath(local bool) string

ToFilePath returns a path to this VTree being: .idv/{local, remote}/vtreeFileName local indicates which of the 2 folders to use

func (VTree) WriteToFolder

func (v VTree) WriteToFolder(folderPath string) error

WriteToFolder writes the tree to the specified folder. Name of file is and should be determined by the tree structure

Directories

Path Synopsis
ctl

Jump to

Keyboard shortcuts

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