updated g2g handle of github api pages
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Paul 2021-12-25 16:39:32 +01:00
parent 174289b1fe
commit 70203a1ae8
5 changed files with 16 additions and 18 deletions

View File

@ -21,17 +21,14 @@ make
request_timeout=1200s
threads=4
github_stars_pages="https://api.github.com/users/%s/starred?page=%d"
github_max_per_page=500
github_page_num=3
github_auth_username="user"
github_auth_password="pass"
gitea_username="user"
gitea_dest_username="user_or_org"
gitea_repo_url_tmpl="https://gogs.example.com/api/v1/repos/%s/%s"
gitea_orgs_url_tmpl="https://git.paulbsd.com/api/v1/orgs/%s"
gitea_migrate_url="https://gogs.example.com/api/v1/repos/migrate"
gitea_repo_url_tmpl="https://git.example.com/api/v1/repos/%s/%s"
gitea_orgs_url_tmpl="https://git.example.com/api/v1/orgs/%s"
gitea_migrate_url="https://git.example.com/api/v1/repos/migrate"
gitea_auth_token="token xxxx"
gitea_mirror=true
```
@ -49,7 +46,7 @@ gitea_mirror=true
## License
```text
Copyright (c) 2020 PaulBSD
Copyright (c) 2020, 2021 PaulBSD
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -1 +1 @@
0.9
1.0.4

View File

@ -2,16 +2,13 @@
request_timeout=1200s
threads=4
github_stars_pages="https://api.github.com/users/%s/starred?page=%d"
github_max_per_page=500
github_page_num=3
github_auth_username="user"
github_auth_password="pass"
gitea_username="user"
gitea_dest_username="user_or_org"
gitea_repo_url_tmpl="https://gogs.example.com/api/v1/repos/%s/%s"
gitea_orgs_url_tmpl="https://gogs.example.com/api/v1/orgs/%s"
gitea_migrate_url="https://gogs.example.com/api/v1/repos/migrate"
gitea_repo_url_tmpl="https://git.example.com/api/v1/repos/%s/%s"
gitea_orgs_url_tmpl="https://git.example.com/api/v1/orgs/%s"
gitea_migrate_url="https://git.example.com/api/v1/repos/migrate"
gitea_auth_token="token xxxx"
gitea_mirror=true

View File

@ -32,8 +32,6 @@ func (config *Config) GetConfig() error {
type Config struct {
G2gRequestTimeout time.Duration `ini:"g2g_request_timeout"`
G2gThreads int `ini:"g2g_threads"`
GitHubMaxPerPage int `ini:"github_max_per_page"`
GitHubPageNum int `ini:"github_page_num"`
GitHubAuthUsername string `ini:"github_auth_username"`
GitHubAuthPassword string `ini:"github_auth_password"`
GitHubContentType string

View File

@ -17,10 +17,11 @@ import (
func GetReposFromGitHub(config *config.Config) ([]GitHubRepo, error) {
var repopartiallist []GitHubRepo
var repofulllist []GitHubRepo
var pagenum = 1
fmt.Println("Getting GitHub starred repos")
for num := 1; num <= config.GitHubPageNum; num++ {
url := fmt.Sprintf("https://api.github.com/users/%s/starred?per_page=%d&page=%d", config.GitHubAuthUsername, config.GitHubMaxPerPage, num)
for {
url := fmt.Sprintf("https://api.github.com/users/%s/starred?page=%d", config.GitHubAuthUsername, pagenum)
fmt.Println(url)
resp, err := GetGitHubResponse(config, url)
@ -38,9 +39,14 @@ func GetReposFromGitHub(config *config.Config) ([]GitHubRepo, error) {
return nil, err
}
if len(repopartiallist) == 0 {
break
}
for _, elem := range repopartiallist {
repofulllist = append(repofulllist, elem)
}
pagenum++
}
fmt.Printf("%d repositories fetched from Github\n", len(repofulllist))