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

configure a user to clone to. for structured cloning #219

Merged
merged 1 commit into from
Apr 3, 2024
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
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
Loading