mirror of
https://github.com/cooperspencer/gickup
synced 2024-10-18 07:38:08 +02:00
adds wiki logic to github and gitlab
This commit is contained in:
parent
8ec9f04715
commit
eb3704b272
@ -1,9 +1,8 @@
|
||||
package gitea
|
||||
|
||||
import (
|
||||
"gickup/types"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gickup/types"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
|
@ -56,7 +56,7 @@ func Get(conf *types.Conf) []types.Repo {
|
||||
for _, r := range githubrepos {
|
||||
if include[*r.Name] {
|
||||
repos = append(repos, types.Repo{Name: r.GetName(), Url: r.GetCloneURL(), SshUrl: r.GetSSHURL(), Token: token, Defaultbranch: r.GetDefaultBranch(), Origin: repo, Owner: r.GetOwner().GetLogin(), Hoster: "github.com"})
|
||||
if *r.HasWiki && repo.Wiki {
|
||||
if *r.HasWiki && repo.Wiki && *r.HasPages {
|
||||
repos = append(repos, types.Repo{Name: *r.Name + ".wiki", Url: types.DotGitRx.ReplaceAllString(r.GetCloneURL(), ".wiki.git"), SshUrl: types.DotGitRx.ReplaceAllString(r.GetSSHURL(), ".wiki.git"), Token: token, Defaultbranch: r.GetDefaultBranch(), Origin: repo, Owner: r.GetOwner().GetLogin(), Hoster: "github.com"})
|
||||
}
|
||||
continue
|
||||
@ -69,7 +69,7 @@ func Get(conf *types.Conf) []types.Repo {
|
||||
}
|
||||
if len(repo.Include) == 0 {
|
||||
repos = append(repos, types.Repo{Name: r.GetName(), Url: r.GetCloneURL(), SshUrl: r.GetSSHURL(), Token: token, Defaultbranch: r.GetDefaultBranch(), Origin: repo, Owner: r.GetOwner().GetLogin(), Hoster: "github.com"})
|
||||
if *r.HasWiki && repo.Wiki {
|
||||
if *r.HasWiki && repo.Wiki && *r.HasPages {
|
||||
repos = append(repos, types.Repo{Name: *r.Name + ".wiki", Url: types.DotGitRx.ReplaceAllString(r.GetCloneURL(), ".wiki.git"), SshUrl: types.DotGitRx.ReplaceAllString(r.GetSSHURL(), ".wiki.git"), Token: token, Defaultbranch: r.GetDefaultBranch(), Origin: repo, Owner: r.GetOwner().GetLogin(), Hoster: "github.com"})
|
||||
}
|
||||
}
|
||||
|
@ -105,9 +105,11 @@ func Get(conf *types.Conf) []types.Repo {
|
||||
}
|
||||
|
||||
if r.WikiEnabled && repo.Wiki {
|
||||
httpUrlToRepo := types.DotGitRx.ReplaceAllString(r.HTTPURLToRepo, ".wiki.git")
|
||||
sshUrlToRepo := types.DotGitRx.ReplaceAllString(r.SSHURLToRepo, ".wiki.git")
|
||||
repos = append(repos, types.Repo{Name: r.Path + ".wiki", Url: httpUrlToRepo, SshUrl: sshUrlToRepo, Token: token, Defaultbranch: r.DefaultBranch, Origin: repo, Owner: r.Owner.Username, Hoster: types.GetHost(repo.Url)})
|
||||
if activeWiki(r, client, repo) {
|
||||
httpUrlToRepo := types.DotGitRx.ReplaceAllString(r.HTTPURLToRepo, ".wiki.git")
|
||||
sshUrlToRepo := types.DotGitRx.ReplaceAllString(r.SSHURLToRepo, ".wiki.git")
|
||||
repos = append(repos, types.Repo{Name: r.Path + ".wiki", Url: httpUrlToRepo, SshUrl: sshUrlToRepo, Token: token, Defaultbranch: r.DefaultBranch, Origin: repo, Owner: r.Owner.Username, Hoster: types.GetHost(repo.Url)})
|
||||
}
|
||||
}
|
||||
|
||||
continue
|
||||
@ -121,9 +123,11 @@ func Get(conf *types.Conf) []types.Repo {
|
||||
}
|
||||
|
||||
if r.WikiEnabled && repo.Wiki {
|
||||
httpUrlToRepo := types.DotGitRx.ReplaceAllString(r.HTTPURLToRepo, ".wiki.git")
|
||||
sshUrlToRepo := types.DotGitRx.ReplaceAllString(r.SSHURLToRepo, ".wiki.git")
|
||||
repos = append(repos, types.Repo{Name: r.Path + ".wiki", Url: httpUrlToRepo, SshUrl: sshUrlToRepo, Token: token, Defaultbranch: r.DefaultBranch, Origin: repo, Owner: r.Owner.Username, Hoster: types.GetHost(repo.Url)})
|
||||
if activeWiki(r, client, repo) {
|
||||
httpUrlToRepo := types.DotGitRx.ReplaceAllString(r.HTTPURLToRepo, ".wiki.git")
|
||||
sshUrlToRepo := types.DotGitRx.ReplaceAllString(r.SSHURLToRepo, ".wiki.git")
|
||||
repos = append(repos, types.Repo{Name: r.Path + ".wiki", Url: httpUrlToRepo, SshUrl: sshUrlToRepo, Token: token, Defaultbranch: r.DefaultBranch, Origin: repo, Owner: r.Owner.Username, Hoster: types.GetHost(repo.Url)})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,9 +178,11 @@ func Get(conf *types.Conf) []types.Repo {
|
||||
}
|
||||
|
||||
if r.WikiEnabled && repo.Wiki {
|
||||
httpUrlToRepo := types.DotGitRx.ReplaceAllString(r.HTTPURLToRepo, ".wiki.git")
|
||||
sshUrlToRepo := types.DotGitRx.ReplaceAllString(r.SSHURLToRepo, ".wiki.git")
|
||||
repos = append(repos, types.Repo{Name: r.Path + ".wiki", Url: httpUrlToRepo, SshUrl: sshUrlToRepo, Token: token, Defaultbranch: r.DefaultBranch, Origin: repo, Owner: k, Hoster: types.GetHost(repo.Url)})
|
||||
if activeWiki(r, client, repo) {
|
||||
httpUrlToRepo := types.DotGitRx.ReplaceAllString(r.HTTPURLToRepo, ".wiki.git")
|
||||
sshUrlToRepo := types.DotGitRx.ReplaceAllString(r.SSHURLToRepo, ".wiki.git")
|
||||
repos = append(repos, types.Repo{Name: r.Path + ".wiki", Url: httpUrlToRepo, SshUrl: sshUrlToRepo, Token: token, Defaultbranch: r.DefaultBranch, Origin: repo, Owner: k, Hoster: types.GetHost(repo.Url)})
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -189,9 +195,11 @@ func Get(conf *types.Conf) []types.Repo {
|
||||
}
|
||||
|
||||
if r.WikiEnabled && repo.Wiki {
|
||||
httpUrlToRepo := types.DotGitRx.ReplaceAllString(r.HTTPURLToRepo, ".wiki.git")
|
||||
sshUrlToRepo := types.DotGitRx.ReplaceAllString(r.SSHURLToRepo, ".wiki.git")
|
||||
repos = append(repos, types.Repo{Name: r.Path + ".wiki", Url: httpUrlToRepo, SshUrl: sshUrlToRepo, Token: token, Defaultbranch: r.DefaultBranch, Origin: repo, Owner: k, Hoster: types.GetHost(repo.Url)})
|
||||
if activeWiki(r, client, repo) {
|
||||
httpUrlToRepo := types.DotGitRx.ReplaceAllString(r.HTTPURLToRepo, ".wiki.git")
|
||||
sshUrlToRepo := types.DotGitRx.ReplaceAllString(r.SSHURLToRepo, ".wiki.git")
|
||||
repos = append(repos, types.Repo{Name: r.Path + ".wiki", Url: httpUrlToRepo, SshUrl: sshUrlToRepo, Token: token, Defaultbranch: r.DefaultBranch, Origin: repo, Owner: k, Hoster: types.GetHost(repo.Url)})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -200,3 +208,15 @@ func Get(conf *types.Conf) []types.Repo {
|
||||
}
|
||||
return repos
|
||||
}
|
||||
|
||||
func activeWiki(r *gitlab.Project, client *gitlab.Client, repo types.GenRepo) bool {
|
||||
wikilistoptions := &gitlab.ListWikisOptions{WithContent: gitlab.Bool(true)}
|
||||
wikis, _, err := client.Wikis.ListWikis(r.ID, wikilistoptions)
|
||||
if err != nil {
|
||||
log.Warn().Str("stage", "gitlab").Str("url", repo.Url).Msg(err.Error())
|
||||
}
|
||||
if len(wikis) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user