mirror of
https://github.com/cooperspencer/gickup.git
synced 2026-10-19 16:16:46 +00:00
Backup description and visibility (#146)
This commit is contained in:
@@ -84,6 +84,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: user,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Is_private,
|
||||
})
|
||||
|
||||
continue
|
||||
@@ -103,6 +105,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: user,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Is_private,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+28
-10
@@ -22,21 +22,21 @@ func getOrgVisibility(visibility string) gitea.VisibleType {
|
||||
}
|
||||
}
|
||||
|
||||
func getRepoVisibility(visibility string) bool {
|
||||
func getRepoVisibility(visibility string, private bool) bool {
|
||||
switch visibility {
|
||||
case "public":
|
||||
return false
|
||||
case "private":
|
||||
return true
|
||||
default:
|
||||
return true
|
||||
return private
|
||||
}
|
||||
}
|
||||
|
||||
// Backup TODO.
|
||||
func Backup(r types.Repo, d types.GenRepo, dry bool) bool {
|
||||
orgvisibilty := getOrgVisibility(d.Visibility.Organizations)
|
||||
repovisibility := getRepoVisibility(d.Visibility.Repositories)
|
||||
repovisibility := getRepoVisibility(d.Visibility.Repositories, r.Private)
|
||||
if d.URL == "" {
|
||||
d.URL = "https://gitea.com/"
|
||||
}
|
||||
@@ -100,13 +100,14 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) bool {
|
||||
repo, _, err := giteaclient.GetRepo(user.UserName, r.Name)
|
||||
if err != nil {
|
||||
opts := gitea.MigrateRepoOption{
|
||||
RepoName: r.Name,
|
||||
RepoOwner: user.UserName,
|
||||
Mirror: true,
|
||||
CloneAddr: r.URL,
|
||||
AuthToken: r.Token,
|
||||
Wiki: r.Origin.Wiki,
|
||||
Private: repovisibility,
|
||||
RepoName: r.Name,
|
||||
RepoOwner: user.UserName,
|
||||
Mirror: true,
|
||||
CloneAddr: r.URL,
|
||||
AuthToken: r.Token,
|
||||
Wiki: r.Origin.Wiki,
|
||||
Private: repovisibility,
|
||||
Description: r.Description,
|
||||
}
|
||||
|
||||
if r.Token == "" {
|
||||
@@ -119,6 +120,7 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) bool {
|
||||
AuthPassword: r.Origin.Password,
|
||||
Wiki: r.Origin.Wiki,
|
||||
Private: repovisibility,
|
||||
Description: r.Description,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,6 +306,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
if r.HasWiki && repo.Wiki && types.StatRemote(r.CloneURL, r.SSHURL, repo) {
|
||||
repos = append(repos, types.Repo{
|
||||
@@ -315,6 +319,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -335,6 +341,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
if r.HasWiki && repo.Wiki && types.StatRemote(r.CloneURL, r.SSHURL, repo) {
|
||||
repos = append(repos, types.Repo{
|
||||
@@ -346,6 +354,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -438,6 +448,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
if r.HasWiki && repo.Wiki && types.StatRemote(r.CloneURL, r.SSHURL, repo) {
|
||||
repos = append(repos, types.Repo{
|
||||
@@ -449,6 +461,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -469,6 +483,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
if r.HasWiki && repo.Wiki && types.StatRemote(r.CloneURL, r.SSHURL, repo) {
|
||||
repos = append(repos, types.Repo{
|
||||
@@ -480,6 +496,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,8 @@ func addWiki(r github.Repository, repo types.GenRepo, token string) types.Repo {
|
||||
Origin: repo,
|
||||
Owner: r.GetOwner().GetLogin(),
|
||||
Hoster: "github.com",
|
||||
Description: r.GetDescription(),
|
||||
Private: r.GetPrivate(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,6 +258,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.GetOwner().GetLogin(),
|
||||
Hoster: "github.com",
|
||||
Description: r.GetDescription(),
|
||||
Private: r.GetPrivate(),
|
||||
})
|
||||
wiki := addWiki(*r, repo, token)
|
||||
if wiki.Name != "" {
|
||||
@@ -285,6 +289,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.GetOwner().GetLogin(),
|
||||
Hoster: "github.com",
|
||||
Description: r.GetDescription(),
|
||||
Private: r.GetPrivate(),
|
||||
})
|
||||
wiki := addWiki(*r, repo, token)
|
||||
if wiki.Name != "" {
|
||||
@@ -301,6 +307,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.GetOwner().GetLogin(),
|
||||
Hoster: "github.com",
|
||||
Description: r.GetDescription(),
|
||||
Private: r.GetPrivate(),
|
||||
})
|
||||
wiki := addWiki(*r, repo, token)
|
||||
if wiki.Name != "" {
|
||||
|
||||
+37
-10
@@ -67,10 +67,20 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) bool {
|
||||
splittedurl[0], r.Origin.User, r.Origin.Password, splittedurl[1])
|
||||
}
|
||||
|
||||
var visibility gitlab.VisibilityValue
|
||||
|
||||
if r.Private {
|
||||
visibility = gitlab.PrivateVisibility
|
||||
} else {
|
||||
visibility = gitlab.PublicVisibility
|
||||
}
|
||||
|
||||
opts := &gitlab.CreateProjectOptions{
|
||||
Mirror: &True,
|
||||
ImportURL: &r.URL,
|
||||
Name: &r.Name,
|
||||
Mirror: &True,
|
||||
ImportURL: &r.URL,
|
||||
Name: &r.Name,
|
||||
Description: &r.Description,
|
||||
Visibility: gitlab.Visibility(visibility),
|
||||
}
|
||||
|
||||
_, _, err = gitlabclient.Projects.CreateProject(opts)
|
||||
@@ -226,6 +236,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Namespace.FullPath,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == gitlab.PrivateVisibility,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -242,6 +254,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Namespace.FullPath,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == gitlab.PrivateVisibility,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -262,6 +276,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Namespace.FullPath,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == gitlab.PrivateVisibility,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -278,6 +294,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Namespace.FullPath,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == gitlab.PrivateVisibility,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -384,6 +402,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: k,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == gitlab.PrivateVisibility,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -400,6 +420,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: k,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == gitlab.PrivateVisibility,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -424,6 +446,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: k,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == gitlab.PrivateVisibility,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -432,13 +456,16 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
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),
|
||||
Name: r.Path + ".wiki",
|
||||
URL: httpURLToRepo,
|
||||
SSHURL: sshURLToRepo,
|
||||
Token: token,
|
||||
Defaultbranch: r.DefaultBranch,
|
||||
Origin: repo,
|
||||
Owner: k,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == gitlab.PrivateVisibility,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) bool {
|
||||
CloneAddr: r.URL,
|
||||
AuthUsername: r.Token,
|
||||
Private: repovisibility,
|
||||
Description: r.Description,
|
||||
}
|
||||
|
||||
if r.Token == "" {
|
||||
@@ -92,6 +93,7 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) bool {
|
||||
AuthUsername: r.Origin.User,
|
||||
AuthPassword: r.Origin.Password,
|
||||
Private: repovisibility,
|
||||
Description: r.Description,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,6 +197,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
if repo.Wiki {
|
||||
repos = append(repos, types.Repo{
|
||||
@@ -206,6 +210,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -226,6 +232,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
if repo.Wiki {
|
||||
repos = append(repos, types.Repo{
|
||||
@@ -237,6 +245,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -313,6 +323,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
if repo.Wiki {
|
||||
repos = append(repos, types.Repo{
|
||||
@@ -324,6 +336,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -344,6 +358,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
|
||||
if repo.Wiki {
|
||||
@@ -356,6 +372,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.UserName,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Private,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: repo.User,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -204,6 +205,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: org,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,6 +228,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.Name,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == "private",
|
||||
})
|
||||
if repo.Wiki {
|
||||
repos = append(repos, types.Repo{
|
||||
@@ -239,6 +241,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.Name,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == "private",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -259,6 +263,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.Name,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == "private",
|
||||
})
|
||||
if repo.Wiki {
|
||||
refs, err := getRefs(apiURL, fmt.Sprintf("%s-docs", r.Name), token)
|
||||
@@ -283,6 +289,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
||||
Origin: repo,
|
||||
Owner: r.Owner.Name,
|
||||
Hoster: types.GetHost(repo.URL),
|
||||
Description: r.Description,
|
||||
Private: r.Visibility == "private",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,6 +338,8 @@ type Repo struct {
|
||||
Origin GenRepo
|
||||
Owner string
|
||||
Hoster string
|
||||
Description string
|
||||
Private bool
|
||||
}
|
||||
|
||||
// Site TODO.
|
||||
|
||||
Reference in New Issue
Block a user