diff options
author | Michael Muré <batolettre@gmail.com> | 2019-08-27 12:11:51 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-11-19 19:51:18 +0100 |
commit | 283e97111b0b39a4e8f7717234f0bfbbb4f481af (patch) | |
tree | 9e797d5e5782d6e46a19c306d09135e5ea5ebce5 /bug/bug.go | |
parent | 67c82f4a2d683e746df5f8af9e0725acd252d29d (diff) | |
download | git-bug-283e97111b0b39a4e8f7717234f0bfbbb4f481af.tar.gz |
bug: make sure there is no Operation's hash collision
Diffstat (limited to 'bug/bug.go')
-rw-r--r-- | bug/bug.go | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -330,12 +330,18 @@ func (bug *Bug) Validate() error { } // Check that there is no more CreateOp op + // Check that there is no colliding operation's ID it := NewOperationIterator(bug) createCount := 0 + ids := make(map[entity.Id]struct{}) for it.Next() { if it.Value().base().OperationType == CreateOp { createCount++ } + if _, ok := ids[it.Value().Id()]; ok { + return fmt.Errorf("id collision: %s", it.Value().Id()) + } + ids[it.Value().Id()] = struct{}{} } if createCount != 1 { |