all repos

mugit @ 8417128

馃惍 git server that your cow will love
2 files changed, 25 insertions(+), 3 deletions(-)
cli: repo create --mirror
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
M internal/cli/cli.go
路路路
        61
        61
         						Arguments: []cli.Argument{

      
        62
        62
         							&cli.StringArg{Name: "name"},

      
        63
        63
         						},

      
        
        64
        +						Flags: []cli.Flag{

      
        
        65
        +							&cli.StringFlag{

      
        
        66
        +								Name:  "mirror",

      
        
        67
        +								Usage: "remote URL(only http/https) to mirror from",

      
        
        68
        +							},

      
        
        69
        +						},

      
        64
        70
         					},

      
        65
        71
         				},

      
        66
        72
         			},

      
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
         }