Documentation
¶
Index ¶
- func Append(storePath, key, line string) error
- func CommitMessage(action, key string) string
- func Exists(storePath string) bool
- 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 StorePathByID(dataDir, id string) (string, bool)
- 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 Exists ¶ added in v0.69.0
Exists reports whether storePath is an initialised store (i.e. it has a .git directory). A path that does not yet hold a store returns false.
func Init ¶
Init initialises the document store at storePath. It creates the directory if it does not exist and sets up a git repository for versioning. Calling Init on an already-initialised store refreshes graith's repository-local Git settings so stores created by older versions do not inherit host settings.
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 StorePathByID ¶ added in v0.69.0
StorePathByID resolves a repo ID as printed by ListStores (the <reponame>-<hash> store directory name) to its on-disk store directory, reporting whether a store with that ID exists. The ID must be a single path segment so it cannot escape the store root. This lets an ID discovered via `gr store ls -a` round-trip back into `--repo`.
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>.