-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissue_comments.go
60 lines (47 loc) · 1.02 KB
/
issue_comments.go
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
50
51
52
53
54
55
56
57
58
59
60
package ghsync
import (
"github.com/google/go-github/github"
"time"
)
func (s *Syncer) syncIssuesComments() error {
return s.data.ForEachRepo(s.syncIssuesCommentsByRepo)
}
func (s *Syncer) syncIssuesCommentsByRepo(r *github.Repository) error {
last, err := s.data.LastUpdatedIssueComment(*r.Name)
if err != nil {
return err
}
var (
page = 1
size = 100
since time.Time
)
if last != nil {
since = *last.UpdatedAt
}
for {
comments, resp, err := s.client.Issues.ListComments(s.conf.Organization, *r.Name, 0, &github.IssueListCommentsOptions{
Sort: "updated",
Direction: "asc",
Since: since,
ListOptions: github.ListOptions{
Page: page,
PerPage: size,
},
})
if err != nil {
return err
}
for i := range comments {
s.logger.Debug().Log("msg", "updating issue comment", "repo", *r.Name, "id", comments[i].ID)
if err := s.data.UpdateIssueComment(&comments[i]); err != nil {
return err
}
}
if resp.NextPage == 0 {
break
}
page++
}
return nil
}