Documentation
¶
Overview ¶
Package syncstate keeps a repo folder's sync state with its orgs: the org revision its files last matched (the base), and a pull that isn't finished (the pending record). docs/designs/publish.md#the-sync-state is its design.
The state lives in the repo, in .anfra/publish/, not in ANFRA_HOME with anfra's other state: it stays true with the folder's files wherever they are, so it moves with them, and a copy carries the base its files match. The folder ignores itself (its own .gitignore holds "*"), so nothing in it is committed, whatever the repo's .gitignore says.
Index ¶
Constants ¶
const DirName = "publish"
DirName is the sync state's folder, in a repo's .anfra/.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conflict ¶
type Conflict struct {
Kind string `json:"kind"`
Files []File `json:"files"`
// MarkerSize is the size of the markers written into the file; 0 when it
// has none, and is resolved only by taking a side.
MarkerSize int `json:"marker_size,omitempty"`
// Resolved is set when a side was taken. A conflict with markers is
// resolved by its file's content, which is checked each time.
Resolved bool `json:"resolved,omitempty"`
}
Conflict is one of a pull's conflicts, as treemerge reported it.
type File ¶
type File struct {
Path string `json:"path"`
Base string `json:"base,omitempty"`
Local string `json:"local,omitempty"`
Org string `json:"org,omitempty"`
}
File is one path a conflict covers, with its three versions as blob ids: the base's, this folder's (local) and the org's. "" is absent.
type Folder ¶
type Folder struct {
// contains filtered or unexported fields
}
Folder is a repo folder's sync state, on disk.
func (Folder) BackupDir ¶
BackupDir is where an unfinished pull keeps the files it changed, for undoing it, each named by its blob id (Pending.Before).
func (Folder) Load ¶
Load reads the sync state. A folder with none has an empty one, or, the first time, the revisions ANFRA_HOME's published.json recorded, as each org's base. Save moves them in.
type Org ¶
type Org struct {
// Base is the org's revision these files last matched: the one last
// published, or pulled with no conflicts left.
Base string `json:"base,omitempty"`
// Pending is a pull that isn't finished; nil when there's none.
Pending *Pending `json:"pending,omitempty"`
}
Org is a folder's sync state with one org.
type Pending ¶
type Pending struct {
// Revision is the org's revision the pull merged: the base once every
// conflict is resolved.
Revision string `json:"revision"`
Stage Stage `json:"state"`
Conflicts []Conflict `json:"conflicts,omitempty"`
// Before is each path the pull wrote or deleted, with its blob id before
// the pull: its content in the backup, named by that id. "" is a path the
// pull created. Undoing the pull, or taking the folder's side, puts these
// back.
Before map[string]string `json:"before,omitempty"`
}
Pending is a pull that isn't finished.