Skip to content

Instantly share code, notes, and snippets.

@carlosmn
Created October 17, 2012 18:57
Show Gist options
  • Save carlosmn/3907400 to your computer and use it in GitHub Desktop.
Save carlosmn/3907400 to your computer and use it in GitHub Desktop.
A mock git-http-backend to test pushing
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