Skip to content

Commit

Permalink
Use same $GIT_URL for upload-pack and ref discovery
Browse files Browse the repository at this point in the history
The refsSuffix used for reference discovery appends ".git" to the repo name, while the upload pack proxying does not. This can result in a 422 response from GitHub instead of a packfile when trying to clone gopkg.in repos (ie driusan/dgit#129), making gopkg.in URLs uncloneable with some third party git clients.

I'm not sure why GitHub doesn't have this issue when cloning with the official git client, but using the same base git url for both /info/refs and /git-upload-pack appears to fix the issue for dgit while not causing any noticeable regressions with real git when I tested this change locally.
  • Loading branch information
driusan authored Oct 14, 2018
1 parent 4a378b5 commit 4b4cd5a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func sendNotFound(resp http.ResponseWriter, msg string, args ...interface{}) {
const refsSuffix = ".git/info/refs?service=git-upload-pack"

func proxyUploadPack(resp http.ResponseWriter, req *http.Request, repo *Repo) {
preq, err := http.NewRequest(req.Method, "https://"+repo.GitHubRoot()+"/git-upload-pack", req.Body)
preq, err := http.NewRequest(req.Method, "https://"+repo.GitHubRoot()+".git/git-upload-pack", req.Body)
if err != nil {
resp.WriteHeader(http.StatusInternalServerError)
resp.Write([]byte(fmt.Sprintf("Cannot create GitHub request: %v", err)))
Expand Down

0 comments on commit 4b4cd5a

Please sign in to comment.