1package bug
2
3import (
4 "github.com/MichaelMure/git-bug/identity"
5 "github.com/MichaelMure/git-bug/repository"
6)
7
8// ClockLoader is the repository.ClockLoader for the Bug entity
9var ClockLoader = repository.ClockLoader{
10 Clocks: []string{creationClockName, editClockName},
11 Witnesser: func(repo repository.ClockedRepo) error {
12 // We don't care about the actual identity so an IdentityStub will do
13 resolver := identity.NewStubResolver()
14 for b := range ReadAllLocalWithResolver(repo, resolver) {
15 if b.Err != nil {
16 return b.Err
17 }
18
19 createClock, err := repo.GetOrCreateClock(creationClockName)
20 if err != nil {
21 return err
22 }
23 err = createClock.Witness(b.Bug.createTime)
24 if err != nil {
25 return err
26 }
27
28 editClock, err := repo.GetOrCreateClock(editClockName)
29 if err != nil {
30 return err
31 }
32 err = editClock.Witness(b.Bug.editTime)
33 if err != nil {
34 return err
35 }
36 }
37
38 return nil
39 },
40}