all repos

mugit @ 3e7e955

馃惍 git server that your cow will love
4 files changed, 30 insertions(+), 0 deletions(-)
ssh: print modt on ssh -T
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-05-09 19:19:00 +0300
Authored at: 2026-05-09 18:27:36 +0300
Change ID: pttuykmxpnsrmsmutxplppzlswtrwysw
Parent: 57f9c82
M CHANGELOG.md
路路路
        20
        20
         - `mugit repo default` changes default branch of a repo.

      
        21
        21
         - `mugit repo sync` syncs specified mirror repo.

      
        22
        22
         - Mirror status now inclues last sync time(when there were changes fetched) and last checked time.

      
        
        23
        +- Add modt for ssh pushes/clones.

      
        23
        24
         - Automatically initialize repository on push.

      
        24
        25
         

      
        25
        26
         ### Bug fixes:

      
M internal/ssh/ssh.go
路路路
        36
        36
         }

      
        37
        37
         

      
        38
        38
         func (s *Shell) HandleCommand(ctx context.Context, cmd string, stdin io.Reader, stdout, stderr io.Writer) error {

      
        
        39
        +	// ssh -T `mugit@host`

      
        
        40
        +	if strings.TrimSpace(cmd) == "" {

      
        
        41
        +		_, err := fmt.Fprintln(stderr, s.cfg.Meta.Modt)

      
        
        42
        +		return err

      
        
        43
        +	}

      
        
        44
        +

      
        39
        45
         	gitCmd, repoName, err := s.parseCommand(cmd)

      
        40
        46
         	if err != nil {

      
        41
        47
         		return s.replyWithGitError(stderr, "access denied: invalid command", err)

      
M internal/ssh/ssh_test.go
路路路
        1
        1
         package ssh

      
        2
        2
         

      
        3
        3
         import (

      
        
        4
        +	"bytes"

      
        4
        5
         	"strings"

      
        5
        6
         	"testing"

      
        6
        7
         

      路路路
        91
        92
         		t.Errorf("AuthorizedKeys() missing SSH key\ngot: %s", result)

      
        92
        93
         	}

      
        93
        94
         }

      
        
        95
        +

      
        
        96
        +func TestShellHandleCommand_modt(t *testing.T) {

      
        
        97
        +	modt := "test modt"

      
        
        98
        +	shell, err := NewShell(&config.Config{Meta: config.MetaConfig{

      
        
        99
        +		Modt: modt,

      
        
        100
        +	}})

      
        
        101
        +	is.Err(t, err, nil)

      
        
        102
        +

      
        
        103
        +	var stdout, stderr bytes.Buffer

      
        
        104
        +	err = shell.HandleCommand(t.Context(), "", strings.NewReader(""), &stdout, &stderr)

      
        
        105
        +	is.Err(t, err, nil)

      
        
        106
        +	is.Equal(t, stdout.String(), "")

      
        
        107
        +

      
        
        108
        +	if !strings.Contains(stderr.String(), modt) {

      
        
        109
        +		t.Fatalf("expected MOTD in stderr\ngot: %s", stderr.String())

      
        
        110
        +	}

      
        
        111
        +}

      
M testscript/ssh-push.txtar
路路路
        40
        40
         exists verify-auto-init/file2.txt

      
        41
        41
         

      
        42
        42
         

      
        
        43
        +# should print MOTD for ssh -T style connections

      
        
        44
        +exec $SSH_WRAPPER ignored

      
        
        45
        +stderr 'Welcome to test mugit!'

      
        
        46
        +

      
        
        47
        +

      
        43
        48
         # should not allow execution of commands

      
        44
        49
         ! exec $SSH_WRAPPER ignored 'echo hi'

      
        45
        50
         stderr 'access denied:'