diff options
author | Michael Muré <batolettre@gmail.com> | 2020-02-09 20:08:12 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-02-09 20:23:38 +0100 |
commit | b3d3612393387c83fa43f908dbb8e2a71068c834 (patch) | |
tree | e4609e21dc74e535d45b38cd7d0504681c544160 /bridge/github/import.go | |
parent | dca85b309a0a82e9993a345964d0831ab2876fb4 (diff) | |
parent | 3caffeef4d2ed25d4eb5d4bfd262f4fc3b92561f (diff) | |
download | git-bug-b3d3612393387c83fa43f908dbb8e2a71068c834.tar.gz |
Merge remote-tracking branch 'origin/master' into cheshirekow-jira
Diffstat (limited to 'bridge/github/import.go')
-rw-r--r-- | bridge/github/import.go | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/bridge/github/import.go b/bridge/github/import.go index 092e3e71..ea0ccba3 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -15,12 +15,6 @@ import ( "github.com/MichaelMure/git-bug/util/text" ) -const ( - metaKeyGithubId = "github-id" - metaKeyGithubUrl = "github-url" - metaKeyGithubLogin = "github-login" -) - // githubImporter implement the Importer interface type githubImporter struct { conf core.Configuration @@ -38,17 +32,7 @@ type githubImporter struct { func (gi *githubImporter) Init(repo *cache.RepoCache, conf core.Configuration) error { gi.conf = conf - opts := []auth.Option{ - auth.WithTarget(target), - auth.WithKind(auth.KindToken), - } - - user, err := repo.GetUserIdentity() - if err == nil { - opts = append(opts, auth.WithUserId(user.Id())) - } - - creds, err := auth.List(repo, opts...) + creds, err := auth.List(repo, auth.WithTarget(target), auth.WithKind(auth.KindToken)) if err != nil { return err } @@ -197,6 +181,11 @@ func (gi *githubImporter) ensureIssue(repo *cache.RepoCache, issue issueTimeline // other edits will be added as CommentEdit operations target, err := b.ResolveOperationWithMetadata(metaKeyGithubId, parseId(issue.Id)) + if err == cache.ErrNoMatchingOp { + // original comment is missing somehow, issuing a warning + gi.out <- core.NewImportWarning(fmt.Errorf("comment ID %s to edit is missing", parseId(issue.Id)), b.Id()) + continue + } if err != nil { return nil, err } @@ -545,10 +534,14 @@ func (gi *githubImporter) ensurePerson(repo *cache.RepoCache, actor *actor) (*ca case "Bot": } + // Name is not necessarily set, fallback to login as a name is required in the identity + if name == "" { + name = string(actor.Login) + } + i, err = repo.NewIdentityRaw( name, email, - string(actor.Login), string(actor.AvatarUrl), map[string]string{ metaKeyGithubLogin: string(actor.Login), @@ -595,7 +588,6 @@ func (gi *githubImporter) getGhost(repo *cache.RepoCache) (*cache.IdentityCache, return repo.NewIdentityRaw( name, "", - string(q.User.Login), string(q.User.AvatarUrl), map[string]string{ metaKeyGithubLogin: string(q.User.Login), |