diff options
Diffstat (limited to 'cmd/git-lfs-authenticate')
-rw-r--r-- | cmd/git-lfs-authenticate/main.go | 64 |
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 @@ | |||
1 | package main | 1 | package main |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "errors" | ||
5 | "fmt" | 4 | "fmt" |
6 | "os" | 5 | "os" |
7 | "os/exec" | ||
8 | "strings" | ||
9 | ) | 6 | ) |
10 | 7 | ||
11 | func die(msg string, args ...any) { | 8 | func die(msg string, args ...any) { |
@@ -16,33 +13,36 @@ func die(msg string, args ...any) { | |||
16 | } | 13 | } |
17 | 14 | ||
18 | func main() { | 15 | func 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 | } |