aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github/export.go
blob: 3c07d682c0e9d3c8dff8ef3ba3acba5e9312373d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
}