2 files changed,
25 insertions(+),
3 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-02-03 00:54:39 +0200
Authored at:
2026-02-03 00:36:49 +0200
Change ID:
utzyrwyttkyzrmvzqxztttzmlqolmsls
Parent:
1a0952a
jump to
| M | internal/cli/cli.go |
| M | internal/cli/repo.go |
M
internal/cli/repo.go
路路路 19 19 20 20 name = strings.TrimRight(name, ".git") + ".git" 21 21 22 - // TODO: check if there's already such repo 23 - 24 22 path, err := securejoin.SecureJoin(c.cfg.Repo.Dir, name) 25 23 if err != nil { 26 24 return err 路路路 30 28 return fmt.Errorf("repository already exists: %s", name) 31 29 } 32 30 33 - return git.Init(path) 31 + if err := git.Init(path); err != nil { 32 + return err 33 + } 34 + 35 + mirrorURL := cmd.String("mirror") 36 + if mirrorURL != "" { 37 + if !strings.HasPrefix(mirrorURL, "http") { 38 + return fmt.Errorf("only http and https remotes are supported") 39 + } 40 + repo, err := git.Open(path, "") 41 + if err != nil { 42 + return fmt.Errorf("failed to open repo for mirror setup: %w", err) 43 + } 44 + if err := repo.SetMirrorRemote(mirrorURL); err != nil { 45 + return fmt.Errorf("failed to set mirror remote: %w", err) 46 + } 47 + } 48 + 49 + return nil 34 50 }