aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operation_pack.go
diff options
context:
space:
mode:
Diffstat (limited to 'bug/operation_pack.go')
-rw-r--r--bug/operation_pack.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/bug/operation_pack.go b/bug/operation_pack.go
index cce1845c..5de60bde 100644
--- a/bug/operation_pack.go
+++ b/bug/operation_pack.go
@@ -20,6 +20,7 @@ type OperationPack struct {
commitHash util.Hash
}
+// ParseOperationPack will deserialize an OperationPack from raw bytes
func ParseOperationPack(data []byte) (*OperationPack, error) {
reader := bytes.NewReader(data)
decoder := gob.NewDecoder(reader)
@@ -35,6 +36,7 @@ func ParseOperationPack(data []byte) (*OperationPack, error) {
return &opp, nil
}
+// Serialize will serialise an OperationPack into raw bytes
func (opp *OperationPack) Serialize() ([]byte, error) {
var data bytes.Buffer
@@ -53,14 +55,18 @@ func (opp *OperationPack) Append(op Operation) {
opp.Operations = append(opp.Operations, op)
}
+// IsEmpty tell if the OperationPack is empty
func (opp *OperationPack) IsEmpty() bool {
return len(opp.Operations) == 0
}
+// IsValid tell if the OperationPack is considered valid
func (opp *OperationPack) IsValid() bool {
return !opp.IsEmpty()
}
+// Write will serialize and store the OperationPack as a git blob and return
+// its hash
func (opp *OperationPack) Write(repo repository.Repo) (util.Hash, error) {
data, err := opp.Serialize()