1
1
mirror of https://github.com/cooperspencer/gickup synced 2024-10-18 13:48:07 +02:00

added the actual comments to the backup of github issues

This commit is contained in:
Andreas Wachter 2024-09-29 12:27:11 +02:00
parent dea1d8cac2
commit 4dc9d8c068
2 changed files with 38 additions and 2 deletions

@ -422,7 +422,7 @@ func GetOrCreate(destination types.GenRepo, repo types.Repo) (string, error) {
func GetIssues(repo *github.Repository, client *github.Client, conf types.GenRepo) map[string]interface{} { func GetIssues(repo *github.Repository, client *github.Client, conf types.GenRepo) map[string]interface{} {
issues := map[string]interface{}{} issues := map[string]interface{}{}
if conf.Issues { if conf.Issues {
listOptions := &github.IssueListByRepoOptions{State: "all", ListOptions: github.ListOptions{Page: 0, PerPage: 100}} listOptions := &github.IssueListByRepoOptions{State: "all", ListOptions: github.ListOptions{Page: 1, PerPage: 100}}
errorcount := 0 errorcount := 0
for { for {
i, response, err := client.Issues.ListByRepo(context.Background(), *repo.Owner.Login, *repo.Name, listOptions) i, response, err := client.Issues.ListByRepo(context.Background(), *repo.Owner.Login, *repo.Name, listOptions)
@ -441,7 +441,36 @@ func GetIssues(repo *github.Repository, client *github.Client, conf types.GenRep
} else { } else {
if len(i) > 0 { if len(i) > 0 {
for _, issue := range i { for _, issue := range i {
issues[strconv.Itoa(*issue.Number)] = issue comments := []*github.IssueComment{}
errorcount := 0
if issue.GetComments() > 0 {
listComments := &github.IssueListCommentsOptions{ListOptions: github.ListOptions{Page: 1, PerPage: 100}}
for {
issue_comments, response, err := client.Issues.ListComments(context.Background(), *repo.Owner.Login, *repo.Name, issue.GetNumber(), listComments)
if err != nil {
if response.StatusCode == http.StatusForbidden {
sub.Error().Err(err).Str("repo", *repo.Name).Msg("can't fetch comments")
break
}
if errorcount < 5 {
sub.Error().Err(err).Str("repo", *repo.Name).Msg("can't fetch comments")
time.Sleep(5 * time.Second)
errorcount++
continue
} else {
break
}
}
if len(issue_comments) > 0 {
comments = append(comments, issue_comments...)
errorcount = 0
listComments.Page++
} else {
break
}
}
}
issues[strconv.Itoa(*issue.Number)] = types.GithubIssue{Issue: *issue, CommentList: comments}
} }
} else { } else {
break break

@ -558,3 +558,10 @@ func (s3 S3Repo) GetKey(accessString string) (string, error) {
return "", fmt.Errorf("accesskey or secretkey are empty") return "", fmt.Errorf("accesskey or secretkey are empty")
} }
// Issues
// GithubIssue
type GithubIssue struct {
github.Issue
CommentList []*github.IssueComment
}