aboutsummaryrefslogtreecommitdiffstats
path: root/bug/identity.go
blob: 2eb2bcaf022bc1ba28fadca4f7a3ec0d677c7b87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package bug

import (
	"github.com/MichaelMure/git-bug/identity"
)

// EnsureIdentities walk the graph of operations and make sure that all Identity
// are properly loaded. That is, it replace all the IdentityStub with the full
// Identity, loaded through a Resolver.
func (bug *Bug) EnsureIdentities(resolver identity.Resolver) error {
	it := NewOperationIterator(bug)

	for it.Next() {
		op := it.Value()
		base := op.base()

		if stub, ok := base.Author.(*identity.IdentityStub); ok {
			i, err := resolver.ResolveIdentity(stub.Id())
			if err != nil {
				return err
			}

			base.Author = i
		}
	}
	return nil
}