d05c13c9f160f6be26538a3687071a8c2ff8a1a7

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

feat(web): add support for http git-upload-archive service

Diff

 1diff --git a/pkg/web/git.go b/pkg/web/git.go
 2index 1980f73af53cda7ff1b594fd4581d7397de0b0f2..91e4d6e2fe97b5e91ef2bf0d7a37238af368d7cf 100644
 3--- a/pkg/web/git.go
 4+++ b/pkg/web/git.go
 5@@ -124,7 +124,7 @@ var gitRoutes = []GitRoute{
 6 	{
 7 		method:  []string{http.MethodPost},
 8 		handler: serviceRpc,
 9-		path:    "/{service:(?:git-upload-pack|git-receive-pack)$}",
10+		path:    "/{service:(?:git-upload-archive|git-upload-pack|git-receive-pack)$}",
11 	},
12 	{
13 		method:  []string{http.MethodGet},
14@@ -274,7 +274,7 @@ func withAccess(next http.Handler) http.HandlerFunc {
15 			}
16 
17 			fallthrough
18-		case service == git.UploadPackService:
19+		case service == git.UploadPackService || service == git.UploadArchiveService:
20 			if repo == nil {
21 				// If the repo doesn't exist, return 404
22 				renderNotFound(w, r)
23@@ -394,7 +394,11 @@ func serviceRpc(w http.ResponseWriter, r *http.Request) {
24 	cmd := git.ServiceCommand{
25 		Stdout: &stdout,
26 		Dir:    dir,
27-		Args:   []string{"--stateless-rpc"},
28+	}
29+
30+	switch service {
31+	case git.UploadPackService, git.ReceivePackService:
32+		cmd.Args = append(cmd.Args, "--stateless-rpc")
33 	}
34 
35 	user := proto.UserFromContext(ctx)