diff options
author | Michael Muré <batolettre@gmail.com> | 2023-08-11 14:50:45 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2023-08-11 14:50:45 +0200 |
commit | 395b6eb1c2de3e229d31d46f8d2afdb3f1d59fab (patch) | |
tree | 6a42d31f00188622912325630e5d14d7123fad79 /entity/dag | |
parent | f0167a1d6068d22af5ffff260e2848f7c14a71b3 (diff) | |
download | git-bug-boostrap-rework.tar.gz git-bug-boostrap-rework.zip |
Diffstat (limited to 'entity/dag')
-rw-r--r-- | entity/dag/op_noop.go | 8 | ||||
-rw-r--r-- | entity/dag/op_set_metadata.go | 8 | ||||
-rw-r--r-- | entity/dag/op_set_metadata_test.go | 8 | ||||
-rw-r--r-- | entity/dag/operation.go | 4 |
4 files changed, 15 insertions, 13 deletions
diff --git a/entity/dag/op_noop.go b/entity/dag/op_noop.go index d8a2a05a..e94b2edf 100644 --- a/entity/dag/op_noop.go +++ b/entity/dag/op_noop.go @@ -5,17 +5,17 @@ import ( "github.com/MichaelMure/git-bug/entity" ) -var _ Operation = &NoOpOperation[entity.Snapshot]{} -var _ entity.OperationDoesntChangeSnapshot = &NoOpOperation[entity.Snapshot]{} +var _ Operation = &NoOpOperation[Snapshot]{} +var _ entity.OperationDoesntChangeSnapshot = &NoOpOperation[Snapshot]{} // NoOpOperation is an operation that does not change the entity state. It can // however be used to store arbitrary metadata in the entity history, for example // to support a bridge feature. -type NoOpOperation[SnapT entity.Snapshot] struct { +type NoOpOperation[SnapT Snapshot] struct { OpBase } -func NewNoOpOp[SnapT entity.Snapshot](opType entity.OperationType, author identity.Interface, unixTime int64) *NoOpOperation[SnapT] { +func NewNoOpOp[SnapT Snapshot](opType entity.OperationType, author identity.Interface, unixTime int64) *NoOpOperation[SnapT] { return &NoOpOperation[SnapT]{ OpBase: NewOpBase(opType, author, unixTime), } diff --git a/entity/dag/op_set_metadata.go b/entity/dag/op_set_metadata.go index 19176183..42749fda 100644 --- a/entity/dag/op_set_metadata.go +++ b/entity/dag/op_set_metadata.go @@ -10,16 +10,16 @@ import ( "github.com/MichaelMure/git-bug/util/text" ) -var _ Operation = &SetMetadataOperation[entity.Snapshot]{} -var _ entity.OperationDoesntChangeSnapshot = &SetMetadataOperation[entity.Snapshot]{} +var _ Operation = &SetMetadataOperation[Snapshot]{} +var _ entity.OperationDoesntChangeSnapshot = &SetMetadataOperation[Snapshot]{} -type SetMetadataOperation[SnapT entity.Snapshot] struct { +type SetMetadataOperation[SnapT Snapshot] struct { OpBase Target entity.Id `json:"target"` NewMetadata map[string]string `json:"new_metadata"` } -func NewSetMetadataOp[SnapT entity.Snapshot](opType entity.OperationType, author identity.Interface, unixTime int64, target entity.Id, newMetadata map[string]string) *SetMetadataOperation[SnapT] { +func NewSetMetadataOp[SnapT Snapshot](opType entity.OperationType, author identity.Interface, unixTime int64, target entity.Id, newMetadata map[string]string) *SetMetadataOperation[SnapT] { return &SetMetadataOperation[SnapT]{ OpBase: NewOpBase(opType, author, unixTime), Target: target, diff --git a/entity/dag/op_set_metadata_test.go b/entity/dag/op_set_metadata_test.go index 591ce9b2..a06f89da 100644 --- a/entity/dag/op_set_metadata_test.go +++ b/entity/dag/op_set_metadata_test.go @@ -12,17 +12,17 @@ import ( "github.com/stretchr/testify/require" ) -var _ entity.Snapshot = &snapshotMock{} +var _ Snapshot = &snapshotMock{} type snapshotMock struct { - ops []entity.Operation + ops []Operation } -func (s *snapshotMock) AllOperations() []entity.Operation { +func (s *snapshotMock) AllOperations() []Operation { return s.ops } -func (s *snapshotMock) AppendOperation(op entity.Operation) { +func (s *snapshotMock) AppendOperation(op Operation) { s.ops = append(s.ops, op) } diff --git a/entity/dag/operation.go b/entity/dag/operation.go index 40bd7da8..5099ad80 100644 --- a/entity/dag/operation.go +++ b/entity/dag/operation.go @@ -12,6 +12,8 @@ import ( "github.com/MichaelMure/git-bug/entity" ) +type Snapshot entity.SnapshotT[Operation] + // Operation is an extended interface for an entity.Operation working with the dag package. type Operation interface { entity.Operation @@ -24,7 +26,7 @@ type Operation interface { setExtraMetadataImmutable(key string, value string) } -type OperationWithApply[SnapT entity.Snapshot] interface { +type OperationWithApply[SnapT Snapshot] interface { Operation // Apply the operation to a Snapshot to create the final state |