Created
October 17, 2012 18:57
-
-
Save carlosmn/3907400 to your computer and use it in GitHub Desktop.
A mock git-http-backend to test pushing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"fmt" | |
"net/http" | |
) | |
func handler(w http.ResponseWriter, req *http.Request) { | |
req.ParseForm() | |
var service string = "" | |
val := req.Form["service"] | |
if len(val) > 0 { | |
service = req.Form["service"][0] | |
} | |
if service == "git-receive-pack" { | |
io.WriteString(w, "001f# service=git-receive-pack\n0000") | |
// pretend we've an empty repo | |
str := fmt.Sprintf("00760000000000000000000000000000000000000000 capabilities^{}%c report-status delete-refs side-band-64k quiet ofs-delta\n", 0) | |
io.WriteString(w, str) | |
io.WriteString(w, "0000") | |
} | |
fmt.Println(req.TransferEncoding) | |
} | |
func main() { | |
http.HandleFunc("/", handler) | |
http.ListenAndServe(":8000", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment