Documentation
¶
Index ¶
- func Append(storePath, key, line string) error
- func CommitMessage(action, key string) string
- func Get(storePath, key string) (string, error)
- func Init(storePath string) error
- func Put(storePath, key, body string) error
- func Remove(storePath, key string) error
- func SharedStorePath(dataDir string) string
- func StorePath(dataDir, repoRoot string) string
- func ValidateKey(key string) error
- type Entry
- type StoreInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶ added in v0.36.0
Append appends a line to the file at key and commits it to the git history. A trailing newline is added if line does not already end with one. The file is created if it does not exist.
func CommitMessage ¶
CommitMessage builds a commit message for a store operation. The first line is "store: <action> <key>". If GRAITH_SESSION_ID is set, trailers are appended after a blank line.
func Init ¶
Init initialises the document store at storePath. It creates the directory if it does not exist and sets up a bare git repository for versioning. Calling Init on an already-initialised store is a no-op.
func Remove ¶
Remove deletes the document at key from the store and commits the deletion. Empty parent directories up to the store root are cleaned up after removal.
func SharedStorePath ¶ added in v0.40.0
SharedStorePath returns the on-disk directory for the shared document store. The shared store is not scoped to any repo.
func StorePath ¶
StorePath returns the on-disk directory for the document store for a given repo. The path is <dataDir>/store/<reponame>-<hash> where reponame is the base name of repoRoot and hash is a 12-character deterministic hex string derived from repoRoot.
func ValidateKey ¶
ValidateKey returns an error if key is not a valid store key.
A valid key must:
- be non-empty
- not start with '/' or '-'
- not contain "..", ".git", or "." path components
- not contain control characters, NUL bytes, or backslashes
- not contain git pathspec characters (*, ?, [, :)
- not be "store.lock"
Types ¶
type StoreInfo ¶
type StoreInfo struct {
Name string `json:"name"`
Path string `json:"path"`
Entries []Entry `json:"entries,omitempty"`
}
StoreInfo describes a discovered store directory.
func ListStores ¶
ListStores enumerates all store directories under dataDir/store/. Each directory is named <reponame>-<hash>.