From 864d3ed33597211f22177fce6ecb7e741db795b5 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 25 Dec 2019 22:55:53 +0100 Subject: bridge: allow to configure and pull without having set a user first - init() only the importer or exporter as required - assign a "default user" user Id to credentials at creation if no user has been set - "bridge auth": also display the user - "bridge auth show": adapt to a potential "default user" user Id - "bridge configure": allow to run without a user set - "bridge pull": allow to run without a user set - "user adopt": replace "default user" by the actual user id when run --- bridge/github/import.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'bridge/github/import.go') diff --git a/bridge/github/import.go b/bridge/github/import.go index 092e3e71..dfc851fd 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -12,6 +12,7 @@ import ( "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/entity" + "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/util/text" ) @@ -47,6 +48,9 @@ func (gi *githubImporter) Init(repo *cache.RepoCache, conf core.Configuration) e if err == nil { opts = append(opts, auth.WithUserId(user.Id())) } + if err == identity.ErrNoIdentitySet { + opts = append(opts, auth.WithUserId(auth.DefaultUserId)) + } creds, err := auth.List(repo, opts...) if err != nil { -- cgit From ee48aef489c91a99b665ab1cd783e241611a3841 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 4 Jan 2020 13:10:53 +0100 Subject: github: warning when the comment to be edited is missing instead of failing fix #286 --- bridge/github/import.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bridge/github/import.go') diff --git a/bridge/github/import.go b/bridge/github/import.go index dfc851fd..39aebccb 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -201,6 +201,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 } -- cgit From ae2f942ef907161af0aba5f3511db72cf9801dca Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 12 Jan 2020 16:38:16 +0100 Subject: more wip --- bridge/github/import.go | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'bridge/github/import.go') diff --git a/bridge/github/import.go b/bridge/github/import.go index 39aebccb..aac4f119 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -12,7 +12,6 @@ import ( "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/entity" - "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/util/text" ) @@ -39,20 +38,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())) - } - if err == identity.ErrNoIdentitySet { - opts = append(opts, auth.WithUserId(auth.DefaultUserId)) - } - - creds, err := auth.List(repo, opts...) + creds, err := auth.List(repo, auth.WithTarget(target), auth.WithKind(auth.KindToken)) if err != nil { return err } -- cgit From 74e91144105790cc997c1d79a7f638e1e3a1f3f8 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Fri, 24 Jan 2020 00:30:13 +0100 Subject: more more wip --- bridge/github/import.go | 2 -- 1 file changed, 2 deletions(-) (limited to 'bridge/github/import.go') diff --git a/bridge/github/import.go b/bridge/github/import.go index aac4f119..f2c9a53d 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -543,7 +543,6 @@ func (gi *githubImporter) ensurePerson(repo *cache.RepoCache, actor *actor) (*ca i, err = repo.NewIdentityRaw( name, email, - string(actor.Login), string(actor.AvatarUrl), map[string]string{ metaKeyGithubLogin: string(actor.Login), @@ -590,7 +589,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), -- cgit From 646fd681ffba59d4a74ec3d99558d2ed70b0106b Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 4 Feb 2020 22:05:34 +0100 Subject: it compiles \o/ --- bridge/github/import.go | 6 ------ 1 file changed, 6 deletions(-) (limited to 'bridge/github/import.go') diff --git a/bridge/github/import.go b/bridge/github/import.go index f2c9a53d..6a4c0110 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 -- cgit From 8773929f963b847841fac0d3c42d6278de69b79c Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 8 Feb 2020 22:04:25 +0100 Subject: github: make sure to have a name --- bridge/github/import.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bridge/github/import.go') diff --git a/bridge/github/import.go b/bridge/github/import.go index 6a4c0110..ea0ccba3 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -534,6 +534,11 @@ 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, -- cgit