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:
Andreas Wachter 2022-12-09 15:45:13 +01:00 committed by GitHub
parent 156f6f52e4
commit 2ec9d55f82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 106 additions and 33 deletions

View file

@ -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().