mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 17:51:44 +03:00
bridge: move export event handling to the CLI
This commit is contained in:
parent
4f856d6f78
commit
1a1e313f30
@ -365,39 +365,21 @@ func (b *Bridge) ImportAll(ctx context.Context) (<-chan ImportResult, error) {
|
||||
return b.ImportAllSince(ctx, time.Time{})
|
||||
}
|
||||
|
||||
func (b *Bridge) ExportAll(ctx context.Context, since time.Time) error {
|
||||
func (b *Bridge) ExportAll(ctx context.Context, since time.Time) (<-chan ExportResult, error) {
|
||||
exporter := b.getExporter()
|
||||
if exporter == nil {
|
||||
return ErrExportNotSupported
|
||||
return nil, ErrExportNotSupported
|
||||
}
|
||||
|
||||
err := b.ensureConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = b.ensureInit()
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
events, err := exporter.ExportAll(ctx, b.repo, since)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
exportedIssues := 0
|
||||
for result := range events {
|
||||
if result.Event != ExportEventNothing {
|
||||
fmt.Println(result.String())
|
||||
}
|
||||
|
||||
switch result.Event {
|
||||
case ExportEventBug:
|
||||
exportedIssues++
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("exported %d issues with %s bridge\n", exportedIssues, b.Name)
|
||||
return nil
|
||||
return exporter.ExportAll(ctx, b.repo, since)
|
||||
}
|
||||
|
@ -63,11 +63,25 @@ func runBridgePush(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
err = b.ExportAll(ctx, time.Time{})
|
||||
events, err := b.ExportAll(ctx, time.Time{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
exportedIssues := 0
|
||||
for result := range events {
|
||||
if result.Event != core.ExportEventNothing {
|
||||
fmt.Println(result.String())
|
||||
}
|
||||
|
||||
switch result.Event {
|
||||
case core.ExportEventBug:
|
||||
exportedIssues++
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("exported %d issues with %s bridge\n", exportedIssues, b.Name)
|
||||
|
||||
// send done signal
|
||||
close(done)
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user