git-bug/bug/clocks.go

38 lines
762 B
Go
Raw Normal View History

package bug
import (
"github.com/MichaelMure/git-bug/repository"
)
// ClockLoader is the repository.ClockLoader for the Bug entity
var ClockLoader = repository.ClockLoader{
Clocks: []string{creationClockName, editClockName},
Witnesser: func(repo repository.ClockedRepo) error {
for b := range ReadAllLocalBugs(repo) {
if b.Err != nil {
return b.Err
}
createClock, err := repo.GetOrCreateClock(creationClockName)
if err != nil {
return err
}
err = createClock.Witness(b.Bug.createTime)
if err != nil {
return err
}
2018-09-13 13:43:47 +03:00
editClock, err := repo.GetOrCreateClock(editClockName)
if err != nil {
return err
}
err = editClock.Witness(b.Bug.editTime)
if err != nil {
return err
}
2018-09-13 13:43:47 +03:00
}
return nil
},
}