diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-08-17 23:46:10 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-08-18 23:50:13 +0200 |
commit | df412430ab35106df57bc32d6dd01bd088bf4735 (patch) | |
tree | ea126fb14a3d5abcdfb66e0128c9cbd044f6cb02 | |
parent | 501a9310807d4c53cf9e28b84d88aebd64a04ead (diff) | |
download | git-bug-df412430ab35106df57bc32d6dd01bd088bf4735.tar.gz |
bridge/github: improve error handling and Nothing events
vendor: add package golang.org/x/sync/errgroup
-rw-r--r-- | Gopkg.lock | 9 | ||||
-rw-r--r-- | Gopkg.toml | 4 | ||||
-rw-r--r-- | bridge/core/export.go | 4 | ||||
-rw-r--r-- | bridge/core/import.go | 4 | ||||
-rw-r--r-- | bridge/github/import.go | 3 | ||||
-rw-r--r-- | bridge/gitlab/import.go | 3 | ||||
-rw-r--r-- | vendor/golang.org/x/sync/AUTHORS | 3 | ||||
-rw-r--r-- | vendor/golang.org/x/sync/CONTRIBUTORS | 3 | ||||
-rw-r--r-- | vendor/golang.org/x/sync/LICENSE | 27 | ||||
-rw-r--r-- | vendor/golang.org/x/sync/PATENTS | 22 | ||||
-rw-r--r-- | vendor/golang.org/x/sync/errgroup/errgroup.go | 66 |
11 files changed, 140 insertions, 8 deletions
@@ -384,6 +384,14 @@ [[projects]] branch = "master" + digest = "1:b521f10a2d8fa85c04a8ef4e62f2d1e14d303599a55d64dabf9f5a02f84d35eb" + name = "golang.org/x/sync" + packages = ["errgroup"] + pruneopts = "UT" + revision = "112230192c580c3556b8cee6403af37a4fc5f28c" + +[[projects]] + branch = "master" digest = "1:3364d01296ce7eeca363e3d530ae63a2092d6f8efb85fb3d101e8f6d7de83452" name = "golang.org/x/sys" packages = [ @@ -481,6 +489,7 @@ "github.com/xanzy/go-gitlab", "golang.org/x/crypto/ssh/terminal", "golang.org/x/oauth2", + "golang.org/x/sync/errgroup", "golang.org/x/text/runes", "golang.org/x/text/transform", ] @@ -75,3 +75,7 @@ [[constraint]] name = "github.com/xanzy/go-gitlab" version = "0.20.0" + +[[constraint]] + branch = "master" + name = "golang.org/x/sync" diff --git a/bridge/core/export.go b/bridge/core/export.go index 55cf5a60..ceae1401 100644 --- a/bridge/core/export.go +++ b/bridge/core/export.go @@ -46,9 +46,9 @@ func (er ExportResult) String() string { return fmt.Sprintf("changed label: %s", er.ID) case ExportEventNothing: if er.ID != "" { - return fmt.Sprintf("ignoring export event %s: %s", er.ID, er.Reason) + return fmt.Sprintf("no actions taken for event %s: %s", er.ID, er.Reason) } - return fmt.Sprintf("ignoring export event: %s", er.Reason) + return fmt.Sprintf("no actions taken: %s", er.Reason) case ExportEventError: if er.ID != "" { return fmt.Sprintf("export error at %s: %s", er.ID, er.Err.Error()) diff --git a/bridge/core/import.go b/bridge/core/import.go index 0961e00b..cff30f61 100644 --- a/bridge/core/import.go +++ b/bridge/core/import.go @@ -49,9 +49,9 @@ func (er ImportResult) String() string { return fmt.Sprintf("new identity: %s", er.ID) case ImportEventNothing: if er.ID != "" { - return fmt.Sprintf("ignoring import event %s: %s", er.ID, er.Reason) + return fmt.Sprintf("no action taken for event %s: %s", er.ID, er.Reason) } - return fmt.Sprintf("ignoring event: %s", er.Reason) + return fmt.Sprintf("no action taken: %s", er.Reason) case ImportEventError: if er.ID != "" { return fmt.Sprintf("import error at id %s: %s", er.ID, er.Err.Error()) diff --git a/bridge/github/import.go b/bridge/github/import.go index 9fef9cb5..7c4deb50 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -369,8 +369,7 @@ func (gi *githubImporter) ensureTimelineComment(repo *cache.RepoCache, b *cache. targetOpID, err := b.ResolveOperationWithMetadata(keyGithubId, parseId(item.Id)) if err == nil { - reason := fmt.Sprintf("comment already imported") - gi.out <- core.NewImportNothing("", reason) + gi.out <- core.NewImportNothing("", "comment already imported") } else if err != cache.ErrNoMatchingOp { // real error return err diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go index 40ac06d3..1391bf88 100644 --- a/bridge/gitlab/import.go +++ b/bridge/gitlab/import.go @@ -99,8 +99,7 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue // resolve bug b, err := repo.ResolveBugCreateMetadata(keyGitlabUrl, issue.WebURL) if err == nil { - reason := fmt.Sprintf("bug already imported") - gi.out <- core.NewImportNothing("", reason) + gi.out <- core.NewImportNothing("", "bug already imported") return b, nil } if err != bug.ErrBugNotExist { diff --git a/vendor/golang.org/x/sync/AUTHORS b/vendor/golang.org/x/sync/AUTHORS new file mode 100644 index 00000000..15167cd7 --- /dev/null +++ b/vendor/golang.org/x/sync/AUTHORS @@ -0,0 +1,3 @@ +# This source code refers to The Go Authors for copyright purposes. +# The master list of authors is in the main Go distribution, +# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/sync/CONTRIBUTORS b/vendor/golang.org/x/sync/CONTRIBUTORS new file mode 100644 index 00000000..1c4577e9 --- /dev/null +++ b/vendor/golang.org/x/sync/CONTRIBUTORS @@ -0,0 +1,3 @@ +# This source code was written by the Go contributors. +# The master list of contributors is in the main Go distribution, +# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/sync/LICENSE b/vendor/golang.org/x/sync/LICENSE new file mode 100644 index 00000000..6a66aea5 --- /dev/null +++ b/vendor/golang.org/x/sync/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/sync/PATENTS b/vendor/golang.org/x/sync/PATENTS new file mode 100644 index 00000000..73309904 --- /dev/null +++ b/vendor/golang.org/x/sync/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/sync/errgroup/errgroup.go b/vendor/golang.org/x/sync/errgroup/errgroup.go new file mode 100644 index 00000000..9857fe53 --- /dev/null +++ b/vendor/golang.org/x/sync/errgroup/errgroup.go @@ -0,0 +1,66 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package errgroup provides synchronization, error propagation, and Context +// cancelation for groups of goroutines working on subtasks of a common task. +package errgroup + +import ( + "context" + "sync" +) + +// A Group is a collection of goroutines working on subtasks that are part of +// the same overall task. +// +// A zero Group is valid and does not cancel on error. +type Group struct { + cancel func() + + wg sync.WaitGroup + + errOnce sync.Once + err error +} + +// WithContext returns a new Group and an associated Context derived from ctx. +// +// The derived Context is canceled the first time a function passed to Go +// returns a non-nil error or the first time Wait returns, whichever occurs +// first. +func WithContext(ctx context.Context) (*Group, context.Context) { + ctx, cancel := context.WithCancel(ctx) + return &Group{cancel: cancel}, ctx +} + +// Wait blocks until all function calls from the Go method have returned, then +// returns the first non-nil error (if any) from them. +func (g *Group) Wait() error { + g.wg.Wait() + if g.cancel != nil { + g.cancel() + } + return g.err +} + +// Go calls the given function in a new goroutine. +// +// The first call to return a non-nil error cancels the group; its error will be +// returned by Wait. +func (g *Group) Go(f func() error) { + g.wg.Add(1) + + go func() { + defer g.wg.Done() + + if err := f(); err != nil { + g.errOnce.Do(func() { + g.err = err + if g.cancel != nil { + g.cancel() + } + }) + } + }() +} |