From b07332d62c347326baade26e3a3c281b83172615 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Tue, 9 Jan 2024 23:22:34 +0100 Subject: Fix makehextag in git-lfs-authenticate (C) --- cmd/git-lfs-authenticate/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cmd/git-lfs-authenticate/main.go') diff --git a/cmd/git-lfs-authenticate/main.go b/cmd/git-lfs-authenticate/main.go index 3db0efe..59ed978 100644 --- a/cmd/git-lfs-authenticate/main.go +++ b/cmd/git-lfs-authenticate/main.go @@ -59,7 +59,7 @@ func main() { os.Exit(1) } - repo := strings.TrimPrefix(path.Clean(strings.TrimSuffix(os.Args[1], ".git")), "/") + repo := strings.TrimPrefix(path.Clean(os.Args[1]), "/") operation := os.Args[2] if operation != "download" && operation != "upload" { fmt.Println(usage) @@ -68,8 +68,11 @@ func main() { if repo == ".." || strings.HasPrefix(repo, "../") { die("highly illegal repo name (Anzeige ist raus)") } + if !strings.HasSuffix(repo, ".git") { + die("expected repo name to have '.git' suffix") + } - repoDir := path.Join(repo + ".git") + repoDir := path.Join(repo) finfo, err := os.Stat(repoDir) if err != nil { if errors.Is(err, fs.ErrNotExist) { @@ -125,12 +128,12 @@ func main() { response := authenticateResponse{ Header: map[string]string{ - "Authorization": "Tag " + tagStr, + "Authorization": "Gitolfs3-Hmac-Sha256 " + tagStr, }, ExpiresIn: int64(expiresIn.Seconds()), HRef: fmt.Sprintf("%s%s?p=1&te=%d", hrefBase, - path.Join(repo+".git", "/info/lfs"), + path.Join(repo, "/info/lfs"), expiresAtUnix, ), } -- cgit v1.2.3