(ctx context.Context, repo *cache.RepoCache)
| 550 | } |
| 551 | |
| 552 | func (gi *githubImporter) getGhost(ctx context.Context, repo *cache.RepoCache) (*cache.IdentityCache, error) { |
| 553 | loginName := "ghost" |
| 554 | // Look first in the cache |
| 555 | i, err := repo.Identities().ResolveIdentityImmutableMetadata(metaKeyGithubLogin, loginName) |
| 556 | if err == nil { |
| 557 | return i, nil |
| 558 | } |
| 559 | if entity.IsErrMultipleMatch(err) { |
| 560 | return nil, err |
| 561 | } |
| 562 | user, err := gi.mediator.User(ctx, loginName) |
| 563 | if err != nil { |
| 564 | return nil, err |
| 565 | } |
| 566 | userName := "" |
| 567 | if user.Name != nil { |
| 568 | userName = string(*user.Name) |
| 569 | } |
| 570 | return repo.Identities().NewRaw( |
| 571 | userName, |
| 572 | "", |
| 573 | string(user.Login), |
| 574 | string(user.AvatarUrl), |
| 575 | nil, |
| 576 | map[string]string{ |
| 577 | metaKeyGithubLogin: string(user.Login), |
| 578 | }, |
| 579 | ) |
| 580 | } |
| 581 | |
| 582 | // parseId converts the unusable githubv4.ID (an interface{}) into a string |
| 583 | func parseId(id githubv4.ID) string { |
no test coverage detected