Skip to content

Commit

Permalink
all: support git clone
Browse files Browse the repository at this point in the history
  • Loading branch information
changkun committed Nov 21, 2021
1 parent a549d63 commit eba9aac
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"context"
"embed"
"fmt"
"html/template"
"io/fs"
"log"
Expand Down Expand Up @@ -132,6 +133,12 @@ func (s *server) xHandler() http.Handler {
importRoot = importPath + "/" + elem
repoRoot = config.Conf.X.RepoPath + "/" + elem

// Handling 'git clone https://changkun.de/x/repo'.
if suffix == "/info/refs" && strings.HasPrefix(req.URL.Query().Get("service"), "git-") && elem != "" {
http.Redirect(w, req, fmt.Sprintf("%s/info/refs?%s", repoRoot, req.URL.RawQuery), http.StatusFound)
return
}

d := &struct {
ImportRoot string
VCS string
Expand Down

0 comments on commit eba9aac

Please sign in to comment.