-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathbackend.go
More file actions
49 lines (37 loc) · 1.73 KB
/
backend.go
File metadata and controls
49 lines (37 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Package backend abstracts SQL execution against a dolt database.
//
// All query results use dolt's CSV format (header + rows) so existing
// parsers in commons work unchanged.
package backend
import "io"
// DB abstracts SQL execution against a dolt database.
type DB interface {
// Query runs a read-only SQL SELECT.
// ref: "" = working copy / HEAD, "branch-name", "remote/main".
// Returns CSV output matching dolt sql -r csv format.
Query(sql, ref string) (string, error)
// Exec runs DML statements and auto-commits on the given branch.
// branch: "" = main, "name" = named branch (created from main if needed).
// Callers pass pure DML only — no DOLT_ADD or DOLT_COMMIT.
// The implementation handles commit semantics internally.
Exec(branch, commitMsg string, signed bool, stmts ...string) error
// Branches returns branch names matching prefix.
Branches(prefix string) ([]string, error)
// DeleteBranch removes a branch.
DeleteBranch(name string) error
// PushBranch pushes a branch to origin. No-op for remote.
PushBranch(branch string, stdout io.Writer) error
// PushMain pushes main to origin. No-op for remote.
PushMain(stdout io.Writer) error
// Sync pulls latest from upstream. No-op for remote.
Sync() error
// MergeBranch merges a branch into main. No-op for remote.
MergeBranch(branch string) error
// DeleteRemoteBranch removes a branch on the origin remote. No-op for remote.
DeleteRemoteBranch(branch string) error
// PushAllRemotes pushes to both upstream and origin with sync retry. No-op for remote.
PushAllRemotes(stdout io.Writer) error
// CanWildWest returns nil if the backend supports wild-west mode (direct
// upstream writes). Returns an error with a user-facing message if not.
CanWildWest() error
}