From eba9aac2d75483db81bbd7cc63af5725eebda7ce Mon Sep 17 00:00:00 2001 From: Changkun Ou Date: Sun, 21 Nov 2021 14:31:18 +0100 Subject: [PATCH] all: support git clone --- server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server.go b/server.go index 8dd3ae3..b84e874 100644 --- a/server.go +++ b/server.go @@ -7,6 +7,7 @@ package main import ( "context" "embed" + "fmt" "html/template" "io/fs" "log" @@ -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