Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added interval #174

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ destination:
user: some-name # can be a user or an organization, it must exist on the system
url: http(s)://url-to-gitea
createorg: true # creates an organization if it doesn't exist already, if no user is set it creates an organization with the name of the original author
mirrorinterval: 2h0m0s # interval to pull changes from source repo
visibility:
repositories: private # private, public, default: private
organizations: private # private, limited, public, default: private
Expand Down
47 changes: 30 additions & 17 deletions gitea/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,29 @@ 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,
Description: r.Description,
RepoName: r.Name,
RepoOwner: user.UserName,
Mirror: true,
CloneAddr: r.URL,
AuthToken: r.Token,
Wiki: r.Origin.Wiki,
Private: repovisibility,
Description: r.Description,
MirrorInterval: d.MirrorInterval,
}

if r.Token == "" {
opts = gitea.MigrateRepoOption{
RepoName: r.Name,
RepoOwner: user.UserName,
Mirror: true,
CloneAddr: r.URL,
AuthUsername: r.Origin.User,
AuthPassword: r.Origin.Password,
Wiki: r.Origin.Wiki,
Private: repovisibility,
Description: r.Description,
RepoName: r.Name,
RepoOwner: user.UserName,
Mirror: true,
CloneAddr: r.URL,
AuthUsername: r.Origin.User,
AuthPassword: r.Origin.Password,
Wiki: r.Origin.Wiki,
Private: repovisibility,
Description: r.Description,
MirrorInterval: d.MirrorInterval,
}
}

Expand All @@ -130,6 +132,17 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) bool {
Str("stage", "gitea").
Str("url", d.URL).
Msg(err.Error())
log.Info().
Str("stage", "gitea").
Str("url", d.URL).
Msgf("deleting %s again", types.Blue(r.Name))
_, err = giteaclient.DeleteRepo(user.UserName, r.Name)
if err != nil {
log.Error().
Str("stage", "gitea").
Str("url", d.URL).
Msgf("couldn't delete %s!", types.Red(r.Name))
}
return false
}

Expand Down
11 changes: 11 additions & 0 deletions gogs/gogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) bool {
Str("stage", "gogs").
Str("url", d.URL).
Msg(err.Error())
log.Info().
Str("stage", "gogs").
Str("url", d.URL).
Msgf("deleting %s again", types.Blue(r.Name))
err = gogsclient.DeleteRepo(user.UserName, r.Name)
if err != nil {
log.Error().
Str("stage", "gogs").
Str("url", d.URL).
Msgf("couldn't delete %s!", types.Red(r.Name))
}
return false
}

Expand Down
41 changes: 21 additions & 20 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,26 +228,27 @@ func (source Source) Count() int {

// GenRepo Generell Repo.
type GenRepo struct {
Token string `yaml:"token"`
TokenFile string `yaml:"token_file"`
User string `yaml:"user"`
Organization string `yaml:"organization"`
SSH bool `yaml:"ssh"`
SSHKey string `yaml:"sshkey"`
Username string `yaml:"username"`
Password string `yaml:"password"`
URL string `yaml:"url"`
Exclude []string `yaml:"exclude"`
ExcludeOrgs []string `yaml:"excludeorgs"`
Include []string `yaml:"include"`
IncludeOrgs []string `yaml:"includeorgs"`
Wiki bool `yaml:"wiki"`
Starred bool `yaml:"starred"`
CreateOrg bool `yaml:"createorg"`
Visibility Visibility `yaml:"visibility"`
Filter Filter `yaml:"filter"`
Force bool `yaml:"force"`
Contributed bool `yaml:"contributed"`
Token string `yaml:"token"`
TokenFile string `yaml:"token_file"`
User string `yaml:"user"`
Organization string `yaml:"organization"`
SSH bool `yaml:"ssh"`
SSHKey string `yaml:"sshkey"`
Username string `yaml:"username"`
Password string `yaml:"password"`
URL string `yaml:"url"`
Exclude []string `yaml:"exclude"`
ExcludeOrgs []string `yaml:"excludeorgs"`
Include []string `yaml:"include"`
IncludeOrgs []string `yaml:"includeorgs"`
Wiki bool `yaml:"wiki"`
Starred bool `yaml:"starred"`
CreateOrg bool `yaml:"createorg"`
Visibility Visibility `yaml:"visibility"`
Filter Filter `yaml:"filter"`
Force bool `yaml:"force"`
Contributed bool `yaml:"contributed"`
MirrorInterval string `yaml:"mirrorinterval"`
}

// Visibility struct
Expand Down
Loading