web frontend for git (tangled's grandpa)
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

routes: disable git push

+9 -6
+9 -6
routes/handler.go
··· 4 4 "log" 5 5 "net/http" 6 6 "path/filepath" 7 - "regexp" 8 7 9 8 "github.com/alexedwards/flow" 10 9 "github.com/sosedoff/gitkit" ··· 16 15 gitsvc *gitkit.Server 17 16 } 18 17 19 - // Checks for gitprotocol-http(5) specific query params; if found, passes 18 + // Checks for gitprotocol-http(5) specific smells; if found, passes 20 19 // the request on to the git http service, else render the web frontend. 21 20 func (dw *depsWrapper) Multiplex(w http.ResponseWriter, r *http.Request) { 22 21 path := flow.Param(r.Context(), "...") 23 22 name := flow.Param(r.Context(), "name") 24 23 name = filepath.Clean(name) 25 - gitCommand := regexp.MustCompile(`git-(upload|receive)-pack`) 24 + 25 + if r.URL.RawQuery == "service=git-receive-pack" { 26 + w.WriteHeader(http.StatusBadRequest) 27 + w.Write([]byte("no pushing allowed!")) 28 + return 29 + } 26 30 27 - if path == "info/refs" && gitCommand.MatchString(r.URL.RawQuery) && r.Method == "GET" { 31 + if path == "info/refs" && r.URL.RawQuery == "service=git-upload-pack" && r.Method == "GET" { 28 32 dw.gitsvc.ServeHTTP(w, r) 29 - } else if gitCommand.MatchString(path) && r.Method == "POST" { 33 + } else if path == "git-upload-pack" && r.Method == "POST" { 30 34 dw.gitsvc.ServeHTTP(w, r) 31 35 } else if r.Method == "GET" { 32 - log.Println("index:", r.URL.String()) 33 36 dw.actualDeps.RepoIndex(w, r) 34 37 } 35 38 }