aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github/import.go
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-05-21 00:16:38 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-05-23 14:21:44 +0200
commita6d85fbdbb98c072b6a8a1d50df97fd55419f5e2 (patch)
tree128680d493a5e5688208cf0401b3d1a994d05c07 /bridge/github/import.go
parent458f4da10179f0a0ff757910d99b38538487cee2 (diff)
downloadgit-bug-a6d85fbdbb98c072b6a8a1d50df97fd55419f5e2.tar.gz
improve github importer and iterator
drop and use query variables instead initialize timeline query variables in the constructor improve naming and add comments to public functions
Diffstat (limited to 'bridge/github/import.go')
-rw-r--r--bridge/github/import.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/bridge/github/import.go b/bridge/github/import.go
index ae3ca81d..2b9e5561 100644
--- a/bridge/github/import.go
+++ b/bridge/github/import.go
@@ -39,12 +39,8 @@ func (gi *githubImporter) Init(conf core.Configuration) error {
return nil
}
-func (gi *githubImporter) Reset() {
- gi.importedIssues = 0
- gi.importedIdentities = 0
-}
-
-// ImportAll .
+// ImportAll iterate over all the configured repository issues and ensure the creation of the
+// missing issues / timeline items / edits / label events ...
func (gi *githubImporter) ImportAll(repo *cache.RepoCache, since time.Time) error {
gi.iterator = NewIterator(gi.conf[keyUser], gi.conf[keyProject], gi.conf[keyToken], since)
@@ -60,9 +56,9 @@ func (gi *githubImporter) ImportAll(repo *cache.RepoCache, since time.Time) erro
}
// loop over timeline items
- for gi.iterator.NextTimeline() {
- if err := gi.ensureTimelineItem(repo, b, gi.iterator.TimelineValue()); err != nil {
- return fmt.Errorf("timeline event creation: %v", err)
+ for gi.iterator.NextTimelineItem() {
+ if err := gi.ensureTimelineItem(repo, b, gi.iterator.TimelineItemValue()); err != nil {
+ return fmt.Errorf("timeline item creation: %v", err)
}
}
@@ -77,8 +73,7 @@ func (gi *githubImporter) ImportAll(repo *cache.RepoCache, since time.Time) erro
return err
}
- fmt.Printf("Successfully imported %d issues from Github\n", gi.importedIssues)
- fmt.Printf("Total imported identities: %d\n", gi.importedIdentities)
+ fmt.Printf("Successfully imported %d issues and %d identities from Github\n", gi.importedIssues, gi.importedIdentities)
return nil
}
@@ -160,6 +155,9 @@ func (gi *githubImporter) ensureIssue(repo *cache.RepoCache, issue issueTimeline
return nil, err
}
+ // importing a new bug
+ gi.importedIssues++
+
continue
}