diff options
| -rw-r--r-- | refstore/doc.go | 2 | ||||
| -rw-r--r-- | refstore/errors.go | 7 | ||||
| -rw-r--r-- | refstore/reading.go | 29 | ||||
| -rw-r--r-- | refstore/transaction.go (renamed from refstore/refstore.go) | 48 | ||||
| -rw-r--r-- | refstore/transactional.go | 11 |
5 files changed, 50 insertions, 47 deletions
diff --git a/refstore/doc.go b/refstore/doc.go new file mode 100644 index 00000000..3d6f3908 --- /dev/null +++ b/refstore/doc.go @@ -0,0 +1,2 @@ +// Package refstore provides interfaces for reference storage backends. +package refstore diff --git a/refstore/errors.go b/refstore/errors.go new file mode 100644 index 00000000..45583440 --- /dev/null +++ b/refstore/errors.go @@ -0,0 +1,7 @@ +package refstore + +import "errors" + +// ErrReferenceNotFound indicates that a reference does not exist in a backend. +// TODO: Interface error? Just like object not found in objectstore. +var ErrReferenceNotFound = errors.New("refstore: reference not found") diff --git a/refstore/reading.go b/refstore/reading.go new file mode 100644 index 00000000..eb499deb --- /dev/null +++ b/refstore/reading.go @@ -0,0 +1,29 @@ +package refstore + +import "codeberg.org/lindenii/furgit/ref" + +// ReadingStore reads Git references. +type ReadingStore interface { + // Resolve resolves a reference name to either a symbolic or detached ref. + // + // Implementations should return value forms (ref.Detached or ref.Symbolic), + // not pointer forms. + // If the reference does not exist, implementations should return + // ErrReferenceNotFound. + Resolve(name string) (ref.Ref, error) + // ResolveFully resolves a reference name to a detached object ID. + // + // Implementations may use backend-local lookup semantics for symbolic hops. + // Callers that need cross-backend symbolic resolution (for example in a + // chain of stores) should prefer repeatedly calling Resolve. + // + // ResolveFully resolves symbolic references only. It does not imply peeling + // annotated tag objects. + ResolveFully(name string) (ref.Detached, error) + // List returns references matching pattern. + // + // The exact pattern language is backend-defined. + List(pattern string) ([]ref.Ref, error) + // Close releases resources associated with the store. + Close() error +} diff --git a/refstore/refstore.go b/refstore/transaction.go index a952ae22..539229c9 100644 --- a/refstore/refstore.go +++ b/refstore/transaction.go @@ -1,52 +1,6 @@ -// Package refstore provides interfaces for reference storage backends. package refstore -import ( - "errors" - - "codeberg.org/lindenii/furgit/objectid" - "codeberg.org/lindenii/furgit/ref" -) - -// ErrReferenceNotFound indicates that a reference does not exist in a backend. -// TODO: Interface error? Just like object not found in objectstore. -var ErrReferenceNotFound = errors.New("refstore: reference not found") - -// ReadingStore reads Git references. -type ReadingStore interface { - // Resolve resolves a reference name to either a symbolic or detached ref. - // - // Implementations should return value forms (ref.Detached or ref.Symbolic), - // not pointer forms. - // If the reference does not exist, implementations should return - // ErrReferenceNotFound. - Resolve(name string) (ref.Ref, error) - // ResolveFully resolves a reference name to a detached object ID. - // - // Implementations may use backend-local lookup semantics for symbolic hops. - // Callers that need cross-backend symbolic resolution (for example in a - // chain of stores) should prefer repeatedly calling Resolve. - // - // ResolveFully resolves symbolic references only. It does not imply peeling - // annotated tag objects. - ResolveFully(name string) (ref.Detached, error) - // List returns references matching pattern. - // - // The exact pattern language is backend-defined. - List(pattern string) ([]ref.Ref, error) - // Close releases resources associated with the store. - Close() error -} - -// TransactionalStore begins atomic reference transactions. -// -// Not every readable reference store is writable. Implementations should only -// satisfy TransactionalStore when they can stage and commit reference updates -// atomically within that backend. -type TransactionalStore interface { - // BeginTransaction creates one new mutable transaction. - BeginTransaction() (Transaction, error) -} +import "codeberg.org/lindenii/furgit/objectid" // Transaction stages reference updates for one atomic commit. // diff --git a/refstore/transactional.go b/refstore/transactional.go new file mode 100644 index 00000000..8f5c32cd --- /dev/null +++ b/refstore/transactional.go @@ -0,0 +1,11 @@ +package refstore + +// TransactionalStore begins atomic reference transactions. +// +// Not every readable reference store is writable. Implementations should only +// satisfy TransactionalStore when they can stage and commit reference updates +// atomically within that backend. +type TransactionalStore interface { + // BeginTransaction creates one new mutable transaction. + BeginTransaction() (Transaction, error) +} |
