mirror of
https://github.com/cooperspencer/gickup.git
synced 2026-10-19 16:16:46 +00:00
added visibility, new create org options and wiki support (#128)
* added visibility, new create org options and wiki support * added gogs * log error instead of fatal
This commit is contained in:
+22
-4
@@ -6,8 +6,20 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func getRepoVisibility(visibility string) bool {
|
||||
switch visibility {
|
||||
case "public":
|
||||
return false
|
||||
case "private":
|
||||
return true
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Backup TODO.
|
||||
func Backup(r types.Repo, d types.GenRepo, dry bool) {
|
||||
repovisibility := getRepoVisibility(d.Visibility.Repositories)
|
||||
log.Info().
|
||||
Str("stage", "gogs").
|
||||
Str("url", d.URL).
|
||||
@@ -23,6 +35,10 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) {
|
||||
Msg(err.Error())
|
||||
}
|
||||
|
||||
if d.User == "" && d.CreateOrg {
|
||||
d.User = r.Owner
|
||||
}
|
||||
|
||||
if d.User != "" {
|
||||
user, err = gogsclient.GetUserInfo(d.User)
|
||||
if err != nil {
|
||||
@@ -59,6 +75,7 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) {
|
||||
Mirror: true,
|
||||
CloneAddr: r.URL,
|
||||
AuthUsername: r.Token,
|
||||
Private: repovisibility,
|
||||
}
|
||||
|
||||
if r.Token == "" {
|
||||
@@ -69,15 +86,16 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) {
|
||||
CloneAddr: r.URL,
|
||||
AuthUsername: r.Origin.User,
|
||||
AuthPassword: r.Origin.Password,
|
||||
Private: repovisibility,
|
||||
}
|
||||
}
|
||||
|
||||
_, err := gogsclient.MigrateRepo(opts)
|
||||
if err != nil {
|
||||
log.Fatal().
|
||||
log.Error().
|
||||
Str("stage", "gogs").
|
||||
Str("url", d.URL).
|
||||
Msg(err.Error())
|
||||
Err(err)
|
||||
}
|
||||
|
||||
return
|
||||
@@ -91,10 +109,10 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) {
|
||||
|
||||
err := gogsclient.MirrorSync(user.UserName, repo.Name)
|
||||
if err != nil {
|
||||
log.Fatal().
|
||||
log.Error().
|
||||
Str("stage", "gogs").
|
||||
Str("url", d.URL).
|
||||
Msg(err.Error())
|
||||
Err(err)
|
||||
}
|
||||
|
||||
log.Info().
|
||||
|
||||
Reference in New Issue
Block a user