diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-06-08 23:14:59 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-06-24 21:20:45 +0200 |
commit | fbb0e836d3d23e5a3e47029c92426090e21615f7 (patch) | |
tree | 8671b23efa14401ac32b8afd38cf630412ec7dba /bridge/github | |
parent | 0424a0fa19cbd2d2110d748a0ff3c014615aa17e (diff) | |
download | git-bug-fbb0e836d3d23e5a3e47029c92426090e21615f7.tar.gz |
[bridge/github] Add exporter implementation
Diffstat (limited to 'bridge/github')
-rw-r--r-- | bridge/github/export.go | 49 | ||||
-rw-r--r-- | bridge/github/export_test.go | 7 | ||||
-rw-r--r-- | bridge/github/github.go | 2 |
3 files changed, 57 insertions, 1 deletions
diff --git a/bridge/github/export.go b/bridge/github/export.go new file mode 100644 index 00000000..3c07d682 --- /dev/null +++ b/bridge/github/export.go @@ -0,0 +1,49 @@ +package github + +import ( + "time" + + "github.com/MichaelMure/git-bug/bridge/core" + "github.com/MichaelMure/git-bug/cache" +) + +// githubImporter implement the Importer interface +type githubExporter struct { + conf core.Configuration +} + +func (ge *githubExporter) Init(conf core.Configuration) error { + ge.conf = conf + return nil +} + +// ExportAll export all event made by the current user to Github +func (ge *githubExporter) ExportAll(repo *cache.RepoCache, since time.Time) error { + identity, err := repo.GetUserIdentity() + if err != nil { + return err + } + + allBugsIds := repo.AllBugsIds() + + // + bugs := make([]*cache.BugCache, 0) + for _, id := range allBugsIds { + b, err := repo.ResolveBug(id) + if err != nil { + return err + } + + // check if user participated in the issue + participants := b.Snapshot().Participants + for _, p := range participants { + if p.Id() == identity.Id() { + bugs = append(bugs, b) + } + } + } + + //TODO: Export bugs/events/editions + + return nil +} diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go new file mode 100644 index 00000000..74e8a656 --- /dev/null +++ b/bridge/github/export_test.go @@ -0,0 +1,7 @@ +package github + +import "testing" + +func TestExporter(t *testing.T) { + +} diff --git a/bridge/github/github.go b/bridge/github/github.go index 3e717ee9..46004dc8 100644 --- a/bridge/github/github.go +++ b/bridge/github/github.go @@ -25,7 +25,7 @@ func (*Github) NewImporter() core.Importer { } func (*Github) NewExporter() core.Exporter { - return nil + return &githubExporter{} } func buildClient(token string) *githubv4.Client { |