Skip to content

Commit

Permalink
configure a user to clone to. for structured cloning (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperspencer authored Apr 3, 2024
1 parent 95336a8 commit bf58b23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion conf.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
# metrics configuration is always used from the first configuration
9 changes: 8 additions & 1 deletion whatever/whatever.go
Original file line number Diff line number Diff line change
Expand Up @@ -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://") {
Expand Down Expand Up @@ -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,
})
}
Expand Down

0 comments on commit bf58b23

Please sign in to comment.