all repos

mugit @ 831d5c63e8c2c573e000efc549b60873339509f5

🐮 git server that your cow will love

mugit/internal/git/paths.go(view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package git

import (
	"fmt"
	"strings"

	securejoin "github.com/cyphar/filepath-securejoin"
)

func ResolveName(name string) string {
	return strings.TrimSuffix(name, ".git") + ".git"
}

func ResolvePath(baseDir, repoName string) (string, error) {
	path, err := securejoin.SecureJoin(baseDir, repoName)
	if err != nil {
		return "", fmt.Errorf("failed to secure join paths: %w", err)
	}
	return path, err
}