aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/git-lfs-authenticate
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
committerLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
commit404aeae4545d2426c089a5f8d5e82dae56f5212b (patch)
tree2d84e00af272b39fc04f3795ae06bc48970e57b5 /cmd/git-lfs-authenticate
parent209d8b0187ed025dec9ac149ebcced3462877bff (diff)
downloadgitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz
gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip
Make Nix builds work
Diffstat (limited to 'cmd/git-lfs-authenticate')
-rw-r--r--cmd/git-lfs-authenticate/main.go64
1 files changed, 32 insertions, 32 deletions
diff --git a/cmd/git-lfs-authenticate/main.go b/cmd/git-lfs-authenticate/main.go
index 7c06a51..41e2dbc 100644
--- a/cmd/git-lfs-authenticate/main.go
+++ b/cmd/git-lfs-authenticate/main.go
@@ -1,11 +1,8 @@
1package main 1package main
2 2
3import ( 3import (
4 "errors"
5 "fmt" 4 "fmt"
6 "os" 5 "os"
7 "os/exec"
8 "strings"
9) 6)
10 7
11func die(msg string, args ...any) { 8func die(msg string, args ...any) {
@@ -16,33 +13,36 @@ func die(msg string, args ...any) {
16} 13}
17 14
18func main() { 15func main() {
19 if len(os.Args) != 3 { 16 // if len(os.Args) != 3 {
20 die("expected 2 arguments [path, operation], got %d", len(os.Args)-1) 17 // die("expected 2 arguments [path, operation], got %d", len(os.Args)-1)
21 } 18 // }
22 19 //
23 path := strings.TrimPrefix(strings.TrimSuffix(os.Args[1], ".git"), "/") 20 // path := strings.TrimPrefix(strings.TrimSuffix(os.Args[1], ".git"), "/")
24 operation := os.Args[2] 21 // operation := os.Args[2]
25 22 //
26 if operation != "download" && operation != "upload" { 23 // if operation != "download" && operation != "upload" {
27 die("expected operation to be in {upload, download}, got %s", operation) 24 // die("expected operation to be in {upload, download}, got %s", operation)
28 } 25 // }
29 26 //
30 user := os.Getenv("GL_USER") 27 // user := os.Getenv("GL_USER")
31 if user == "" { 28 //
32 die("expected Gitolite user env (GL_USER) to be set") 29 // if user == "" {
33 } 30 // die("expected Gitolite user env (GL_USER) to be set")
34 31 // }
35 gitolitePerm := "R" 32 //
36 if operation == "upload" { 33 // gitolitePerm := "R"
37 gitolitePerm = "W" 34 //
38 } 35 // if operation == "upload" {
39 36 // gitolitePerm = "W"
40 // gitolite access -q: returns only exit code 37 // }
41 cmd := exec.Command("gitolite", "access", "-q", path, user, gitolitePerm) 38 //
42 err := cmd.Run() 39 // // gitolite access -q: returns only exit code
43 permGranted := err == nil 40 // cmd := exec.Command("gitolite", "access", "-q", path, user, gitolitePerm)
44 var exitErr *exec.ExitError 41 // err := cmd.Run()
45 if err != nil && !errors.As(err, &exitErr) { 42 // permGranted := err == nil
46 die("failed to query Gitolite access information") 43 // var exitErr *exec.ExitError
47 } 44 //
45 // if err != nil && !errors.As(err, &exitErr) {
46 // die("failed to query Gitolite access information")
47 // }
48} 48}