diff --git a/conf.example.yml b/conf.example.yml index 4d6aaa4..48f7eb9 100644 --- a/conf.example.yml +++ b/conf.example.yml @@ -192,6 +192,7 @@ source: lastactivity: 1y # only clone repos which had activity during the last year any: - url: url-to-any-repo # can be https, http or ssh + user: your-preferred-user # the user to want to associate with this repo, default: git username: your-user # user is used to clone the repo with password: your-password ssh: true # can be true or false @@ -289,4 +290,4 @@ metrics: # like "mirror all repos from github to gitea but keep gitlab repos up-to-date in ~/backup" # if cron is defined in the first config, this cron interval will be used for all the other confgurations, except it has one of its own. # if cron is not enabled for the first config, cron will not run for any other configuration -# metrics configuration is always used from the first configuration \ No newline at end of file +# metrics configuration is always used from the first configuration diff --git a/whatever/whatever.go b/whatever/whatever.go index 2040477..67d72f8 100644 --- a/whatever/whatever.go +++ b/whatever/whatever.go @@ -32,6 +32,13 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { var auth transport.AuthMethod hoster := "local" + if repo.User == "" { + if repo.Username != "" { + repo.User = repo.Username + } else { + repo.User = "git" + } + } if _, err := os.Stat(repo.URL); os.IsNotExist(err) { hoster = types.GetHost(repo.URL) if strings.HasPrefix(repo.URL, "http://") || strings.HasPrefix(repo.URL, "https://") { @@ -97,7 +104,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { Token: repo.GetToken(), Defaultbranch: main, Origin: repo, - Owner: "git", + Owner: repo.User, Hoster: hoster, }) }