2 files changed,
11 insertions(+),
10 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-03-11 13:16:32 +0200
Authored at:
2026-03-11 12:09:43 +0200
Change ID:
klolqulrsruxzvtkxrlmwoxwnkyysmpt
Parent:
3590ac8
jump to
| M | internal/cli/repo.go |
| M | internal/mirror/mirror.go |
M
internal/cli/repo.go
路路路 10 10 securejoin "github.com/cyphar/filepath-securejoin" 11 11 "github.com/urfave/cli/v3" 12 12 "olexsmir.xyz/mugit/internal/git" 13 + "olexsmir.xyz/mugit/internal/mirror" 13 14 ) 14 15 15 16 func (c *Cli) repoNewAction(ctx context.Context, cmd *cli.Command) error { 路路路 42 43 43 44 mirrorURL := cmd.String("mirror") 44 45 if mirrorURL != "" { 45 - if !strings.HasPrefix(mirrorURL, "http") { 46 - return fmt.Errorf("only http and https remotes are supported") 46 + if err := mirror.IsRemoteSupported(mirrorURL); err != nil { 47 + return err 47 48 } 48 49 if err := repo.SetMirrorRemote(mirrorURL); err != nil { 49 50 return fmt.Errorf("failed to set mirror remote: %w", err)
M
internal/mirror/mirror.go
路路路 16 16 "olexsmir.xyz/mugit/internal/git" 17 17 ) 18 18 19 +func IsRemoteSupported(remote string) error { 20 + if !strings.HasPrefix(remote, "http") { 21 + return fmt.Errorf("only http and https remotes are supported") 22 + } 23 + return nil 24 +} 25 + 19 26 type Worker struct { 20 27 c *config.Config 21 28 } 路路路 88 95 return err 89 96 } 90 97 91 - if err := w.isSupportedRemote(remoteURL); err != nil { 98 + if err := IsRemoteSupported(remoteURL); err != nil { 92 99 slog.Error("mirror: remote is not valid", "repo", name, "err", err) 93 100 return err 94 101 } 路路路 145 152 } 146 153 147 154 return repos, nil 148 -} 149 - 150 -func (w *Worker) isSupportedRemote(remote string) error { 151 - if !strings.HasPrefix(remote, "http") { 152 - return fmt.Errorf("only http and https remotes are supported") 153 - } 154 - return nil 155 155 } 156 156 157 157 func (w *Worker) isRemoteGithub(remoteURL string) bool {