mirror of
https://github.com/cooperspencer/gickup.git
synced 2025-05-11 17:55:34 +02:00
backup issues from github (#185)
* backup issues from github * gitlab issues * added gitea * added gogs * added onedev * updated examples * added more documentation
This commit is contained in:
parent
a7f72fc9ce
commit
52a834b42b
8 changed files with 209 additions and 8 deletions
29
gogs/gogs.go
29
gogs/gogs.go
|
@ -1,6 +1,7 @@
|
|||
package gogs
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/cooperspencer/gickup/logger"
|
||||
|
@ -194,6 +195,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
|||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
Issues: GetIssues(r, client, repo),
|
||||
})
|
||||
if repo.Wiki {
|
||||
repos = append(repos, types.Repo{
|
||||
|
@ -229,6 +231,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
|||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
Issues: GetIssues(r, client, repo),
|
||||
})
|
||||
if repo.Wiki {
|
||||
repos = append(repos, types.Repo{
|
||||
|
@ -319,6 +322,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
|||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
Issues: GetIssues(r, client, repo),
|
||||
})
|
||||
if repo.Wiki {
|
||||
repos = append(repos, types.Repo{
|
||||
|
@ -354,6 +358,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
|||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
Issues: GetIssues(r, client, repo),
|
||||
})
|
||||
|
||||
if repo.Wiki {
|
||||
|
@ -376,3 +381,27 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
|||
|
||||
return repos, ran
|
||||
}
|
||||
|
||||
// GetIssues get issues
|
||||
func GetIssues(repo *gogs.Repository, client *gogs.Client, conf types.GenRepo) map[string]interface{} {
|
||||
issues := map[string]interface{}{}
|
||||
if conf.Issues {
|
||||
listOptions := gogs.ListIssueOption{State: "all"}
|
||||
for {
|
||||
i, err := client.ListRepoIssues(repo.Owner.UserName, repo.Name, listOptions)
|
||||
if err != nil {
|
||||
sub.Error().Err(err).Str("repo", repo.Name).Msg("can't fetch issues")
|
||||
} else {
|
||||
if len(i) > 0 {
|
||||
for _, issue := range i {
|
||||
issues[strconv.Itoa(int(issue.Index))] = issue
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
listOptions.Page++
|
||||
}
|
||||
}
|
||||
}
|
||||
return issues
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue