Documentation ¶
Index ¶
- Constants
- Variables
- func AddFile(file_to_add io.ReadSeeker, file_path string, tx *sql.Tx) error
- func AddFiles(work_tree string, file_paths []string) error
- func AddParmsToDSN(dsn_url *url.URL, parms map[string][]string) (*url.URL, error)
- func CommitWorktree(work_tree, message, author, committer string) error
- func CopyOps(ops map[string][]string) map[string][]string
- func GetExistingRepoDB(work_tree string) (*sql.DB, error)
- func GetExistingWorktreeDB(work_tree string) (*sql.DB, error)
- func GetRepoDBUri(work_tree string) (db_uri, db_type string, err error)
- func GetWorktreeDBPath(work_tree string) string
- func InitLocal(repo_file, default_branch string, inner_thunk ThunkErr) error
- func InitLocalAll(repo_file, work_tree, default_branch string) error
- func InitWorkTree(work_tree, default_branch string, inner_thunk ThunkErr) error
- func InitWorkTreeConfig(work_tree string, inner_thunk ThunkErr) error
- func NilThunk()
- func NilThunkAny() any
- func NilThunkErr() error
- func SliceContains[T comparable](slc []T, comp T) bool
- func SqliteDSN(path string, parms map[string][]string) string
- type Commit
- type FileHashPair
- type HashAlgorithm
- type HashType
- type HashValue
- type HashValueGenerator
- type Hashable
- type HavartiState
- func (hs *HavartiState) AllowUnsafeTemporarily(thnk ThunkErr) error
- func (hs *HavartiState) ConnectToRepoDB(writable, create bool) (*sql.DB, error)
- func (hs *HavartiState) GetDSN() (*url.URL, error)
- func (hs *HavartiState) GetOriginalWorkDir() (string, error)
- func (hs *HavartiState) GetWorkTree() (string, error)
- func (hs *HavartiState) InitLocalAll(default_branch string) error
- func (hs *HavartiState) SetWorkTree(workTree string)
- func (hs *HavartiState) Status() (*RepoStat, error)
- type HeaderMap
- type HvrtConfig
- type NamedHash
- type RepoStat
- type Thunk
- type ThunkAny
- type ThunkErr
- type Tree
- type TreeMember
Constants ¶
const HashValueDelimiter = ":"
const (
WorkTreeConfigDir = ".hvrt"
)
Variables ¶
var ( NotImplementedError error = errors.New("feature not yet implemented") MissingDSNError error = errors.New("DSN is empty") )
var BareVersion string
var FSError = errors.New("Could not initialize due to issue with error")
var FormattedVersion string
var SQLDialectToDrivers = map[string]string{ "sqlite": sqliteshim.ShimName, "postgres": "postgresql", }
var SQLFiles embed.FS
SQL files for all operations for all supported DB dialects
var SQLStrings_sqlite_work_tree_read_head_commit string
var SqliteDefaultOpts = map[string][]string{
"mode": {"rwc"},
"_txlock": {"immediate"},
"_pragma": {"journal_mode(WAL)", "case_sensitive_like(1)", "foreign_keys(1)"},
}
var WorkTreeDBName = "work_tree_state.sqlite"
Functions ¶
func AddFile ¶
FIXME: pass prepared statements as a map or something, so that they can be bound to the transaction and be reused/cached across multiple calls to the singular `AddFile` function, instead of being prepared again each time the function is called. Reusing prepared statements this way, we should see a big performance increase, which will make a difference when we are adding lots of files within a single transaction.
func AddParmsToDSN ¶
func CommitWorktree ¶
func GetRepoDBUri ¶
func GetWorktreeDBPath ¶
func InitLocalAll ¶
func InitWorkTree ¶
func InitWorkTreeConfig ¶
func NilThunkAny ¶
func NilThunkAny() any
func NilThunkErr ¶
func NilThunkErr() error
func SliceContains ¶
func SliceContains[T comparable](slc []T, comp T) bool
Types ¶
type FileHashPair ¶
func HashFile ¶
func HashFile(file_path string) (FileHashPair, error)
type HashAlgorithm ¶
type HashAlgorithm string
const (
SHA3_256 HashAlgorithm = "sha3-256"
)
HashAlgorithm constants
type HashValue ¶
type HashValue struct { Type HashType Algorithm HashAlgorithm HexDigest string }
func CalculateFileID ¶
func (HashValue) ToStringSlice ¶
type HashValueGenerator ¶
type Hashable ¶
type Hashable interface { // bytes to pass to a hash.Hash instance HashBytes() []byte }
type HavartiState ¶
type HavartiState struct { // Flag to allow potentially unsafe operations that could lose history AllowUnsafe bool // Verbosity level Verbosity int // contains filtered or unexported fields }
Struct definition that contains all state required to run an instance of Havarti
func NewHavartiState ¶
func NewHavartiState(workTreeFS fs.FS, cwd *string, workTree *string, dataSourceName string, dbDriverName string) (*HavartiState, error)
Function to return a new HavartiState
func (*HavartiState) AllowUnsafeTemporarily ¶
func (hs *HavartiState) AllowUnsafeTemporarily(thnk ThunkErr) error
Set HavartState to allow potentially unsafe operations during the duration of the thunk. When the thunk returns, the state will be restored to its previous value. If the value is changed during the duration of the thunk, that value will be overwritten by the restored previous value. Any error returned by the thunk is returned by this method.
func (*HavartiState) ConnectToRepoDB ¶
func (hs *HavartiState) ConnectToRepoDB(writable, create bool) (*sql.DB, error)
func (*HavartiState) GetOriginalWorkDir ¶
func (hs *HavartiState) GetOriginalWorkDir() (string, error)
func (*HavartiState) GetWorkTree ¶
func (hs *HavartiState) GetWorkTree() (string, error)
func (*HavartiState) InitLocalAll ¶
func (hs *HavartiState) InitLocalAll(default_branch string) error
func (*HavartiState) SetWorkTree ¶
func (hs *HavartiState) SetWorkTree(workTree string)
Set HavartState workTree
func (*HavartiState) Status ¶
func (hs *HavartiState) Status() (*RepoStat, error)
Method that returns the status of a repo given a HavartiState struct pointer
type HvrtConfig ¶
type NamedHash ¶
type NamedHash interface { hash.Hash Name() HashAlgorithm HashBytes(t HashType, b []byte) HashValue HashReader(r io.Reader) HashValue }
Implements `hash.Hash` interface, but also returns the name of the algorithm used for the hash.
func NewNamedHash ¶
func NewNamedHash(name HashAlgorithm) (NamedHash, error)
type Tree ¶
type Tree struct {
Members []TreeMember
}
type TreeMember ¶
func (*TreeMember) HashBytes ¶
func (t *TreeMember) HashBytes() []byte