Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit f4d4b2f

Browse files
authored
Merge pull request git-bug#166 from MichaelMure/github-exporter
[Bridge] GitHub exporter
2 parents aa4464d + 9e611ee commit f4d4b2f

30 files changed

+2469
-66
lines changed

Gopkg.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+22-14
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,31 @@ The web UI interact with the backend through a GraphQL API. The schema is availa
116116

117117
### Importer implementations
118118

119-
| | Github | Launchpad |
120-
| ----------------------------------------------- | :----------------: | :----------------: |
121-
| **incremental**<br/>(can import more than once) | :heavy_check_mark: | :x: |
122-
| **with resume**<br/>(download only new data) | :x: | :x: |
123-
| **identities** | :heavy_check_mark: | :heavy_check_mark: |
124-
| identities update | :x: | :x: |
125-
| **bug** | :heavy_check_mark: | :heavy_check_mark: |
126-
| comments | :heavy_check_mark: | :heavy_check_mark: |
127-
| comment editions | :heavy_check_mark: | :x: |
128-
| labels | :heavy_check_mark: | :x: |
129-
| status | :heavy_check_mark: | :x: |
130-
| title edition | :heavy_check_mark: | :x: |
131-
| **automated test suite** | :x: | :x: |
119+
| | Github | Launchpad |
120+
| --- | --- | --- |
121+
| **incremental**<br/>(can import more than once) | :heavy_check_mark: | :x: |
122+
| **with resume**<br/>(download only new data) | :x: | :x: |
123+
| **identities** | :heavy_check_mark: | :heavy_check_mark: |
124+
| identities update | :x: | :x: |
125+
| **bug** | :heavy_check_mark: | :heavy_check_mark: |
126+
| comments | :heavy_check_mark: | :heavy_check_mark: |
127+
| comment editions | :heavy_check_mark: | :x: |
128+
| labels | :heavy_check_mark: | :x: |
129+
| status | :heavy_check_mark: | :x: |
130+
| title edition | :heavy_check_mark: | :x: |
131+
| **automated test suite** | :heavy_check_mark: | :x: |
132132

133133
### Exporter implementations
134134

135-
Todo !
135+
| | Github | Launchpad |
136+
| --- | --- | --- |
137+
| **bug** | :heavy_check_mark: | :x: |
138+
| comments | :heavy_check_mark: | :x: |
139+
| comment editions | :heavy_check_mark: | :x: |
140+
| labels | :heavy_check_mark: | :x: |
141+
| status | :heavy_check_mark: | :x: |
142+
| title edition | :heavy_check_mark: | :x: |
143+
| **automated test suite** | :heavy_check_mark: | :x: |
136144

137145
## Internals
138146

bridge/core/bridge.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,20 @@ func (b *Bridge) ImportAll(since time.Time) error {
297297
return importer.ImportAll(b.repo, since)
298298
}
299299

300-
func (b *Bridge) ExportAll(since time.Time) error {
300+
func (b *Bridge) ExportAll(since time.Time) (<-chan ExportResult, error) {
301301
exporter := b.getExporter()
302302
if exporter == nil {
303-
return ErrExportNotSupported
303+
return nil, ErrExportNotSupported
304304
}
305305

306306
err := b.ensureConfig()
307307
if err != nil {
308-
return err
308+
return nil, err
309309
}
310310

311311
err = b.ensureInit()
312312
if err != nil {
313-
return err
313+
return nil, err
314314
}
315315

316316
return exporter.ExportAll(b.repo, since)

bridge/core/export.go

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package core
2+
3+
import "fmt"
4+
5+
type ExportEvent int
6+
7+
const (
8+
_ ExportEvent = iota
9+
ExportEventBug
10+
ExportEventComment
11+
ExportEventCommentEdition
12+
ExportEventStatusChange
13+
ExportEventTitleEdition
14+
ExportEventLabelChange
15+
ExportEventNothing
16+
)
17+
18+
type ExportResult struct {
19+
Err error
20+
Event ExportEvent
21+
ID string
22+
Reason string
23+
}
24+
25+
func (er ExportResult) String() string {
26+
switch er.Event {
27+
case ExportEventBug:
28+
return "new issue"
29+
case ExportEventComment:
30+
return "new comment"
31+
case ExportEventCommentEdition:
32+
return "updated comment"
33+
case ExportEventStatusChange:
34+
return "changed status"
35+
case ExportEventTitleEdition:
36+
return "changed title"
37+
case ExportEventLabelChange:
38+
return "changed label"
39+
case ExportEventNothing:
40+
return fmt.Sprintf("no event: %v", er.Reason)
41+
default:
42+
panic("unknown export result")
43+
}
44+
}
45+
46+
func NewExportError(err error, reason string) ExportResult {
47+
return ExportResult{
48+
Err: err,
49+
Reason: reason,
50+
}
51+
}
52+
53+
func NewExportNothing(id string, reason string) ExportResult {
54+
return ExportResult{
55+
ID: id,
56+
Reason: reason,
57+
Event: ExportEventNothing,
58+
}
59+
}
60+
61+
func NewExportBug(id string) ExportResult {
62+
return ExportResult{
63+
ID: id,
64+
Event: ExportEventBug,
65+
}
66+
}
67+
68+
func NewExportComment(id string) ExportResult {
69+
return ExportResult{
70+
ID: id,
71+
Event: ExportEventComment,
72+
}
73+
}
74+
75+
func NewExportCommentEdition(id string) ExportResult {
76+
return ExportResult{
77+
ID: id,
78+
Event: ExportEventCommentEdition,
79+
}
80+
}
81+
82+
func NewExportStatusChange(id string) ExportResult {
83+
return ExportResult{
84+
ID: id,
85+
Event: ExportEventStatusChange,
86+
}
87+
}
88+
89+
func NewExportLabelChange(id string) ExportResult {
90+
return ExportResult{
91+
ID: id,
92+
Event: ExportEventLabelChange,
93+
}
94+
}
95+
96+
func NewExportTitleEdition(id string) ExportResult {
97+
return ExportResult{
98+
ID: id,
99+
Event: ExportEventTitleEdition,
100+
}
101+
}

bridge/core/interfaces.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ type Importer interface {
3434

3535
type Exporter interface {
3636
Init(conf Configuration) error
37-
ExportAll(repo *cache.RepoCache, since time.Time) error
37+
ExportAll(repo *cache.RepoCache, since time.Time) (<-chan ExportResult, error)
3838
}

0 commit comments

Comments
 (0)