vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Serve repositories from the root of the URL space
ed03b3d1fa16ef6b55e2773aaf10e3be13282c3a · Keenan Nemetz · 4h ago · parent d37d301f
Serve repositories from the root of the URL space A repository is now /<name> and its Git transport /<name>.git, so the URL a person opens, the URL a clone uses, and the Go module path are the same name. The forge's own pages moved under /-/ (admin, accounts, the directory, the feed, sign-in, assets), a prefix no repository name can start with: names are [a-z0-9...] and cannot begin with "-". That leaves the router with two disjoint spaces and removes the /r/ and /git/ prefixes, which existed only to keep repositories away from the forge's own paths. Routes: repoRoutes lose /r/; global, auth and admin routes gain /-/; assets move to /-/static/ because a subtree pattern like /static/ cannot coexist with one-segment-wildcard repo routes — Go's mux reports them as conflicting neither-more-specific patterns. The catch-all still renders the styled 404. Transport: githttp.Route parses /<name>.git/<rest> instead of a /git/ prefix, and forgepaths.go hands such requests to the proxy before the mux, because a wildcard fills a whole segment and cannot match "<name>.git". LFS stays on the mux (<name>.git/info/lfs/...), and the Go module discovery probe moves to the same pre-router so a package path under a public repository is answered even when its first segments name a page tab. Names: repo.ValidateName now refuses the four root paths the forge must keep — static, robots.txt, sitemap.xml, sitemap-pages.xml. Everything else is an ordinary repository name, including admin, u, and activity. Docs and the packaged URLs follow the new layout; robots.txt, the sitemaps and the instance activity feed point at the new paths. No aliases: the old /r/ and /git/ URLs are gone. Verified with ./vole workflow check and ./vole workflow run verify.
server/githttp/limits_test.go +16−16
| @@ -48,7 +48,7 @@ func newProxyWith(t *testing.T, tweak func(*Config)) (*Proxy, string) { | |||
| 48 | 48 | func TestOversizedBodyRefused(t *testing.T) { | |
| 49 | 49 | t.Parallel() | |
| 50 | 50 | p := newProxy(t, true) | |
| 51 | req := httptest.NewRequest(http.MethodPost, "/git/demo.git/git-upload-pack", | ||
| 51 | req := httptest.NewRequest(http.MethodPost, "/demo.git/git-upload-pack", | ||
| 52 | 52 | strings.NewReader(strings.Repeat("x", maxUploadPackBody+1))) | |
| 53 | 53 | req.ContentLength = maxUploadPackBody + 1 | |
| 54 | 54 | rec := httptest.NewRecorder() | |
| @@ -61,7 +61,7 @@ func TestOversizedBodyRefused(t *testing.T) { | |||
| 61 | 61 | func TestEmptyPostRefused(t *testing.T) { | |
| 62 | 62 | t.Parallel() | |
| 63 | 63 | p := newProxy(t, true) | |
| 64 | req := httptest.NewRequest(http.MethodPost, "/git/demo.git/git-upload-pack", strings.NewReader("")) | ||
| 64 | req := httptest.NewRequest(http.MethodPost, "/demo.git/git-upload-pack", strings.NewReader("")) | ||
| 65 | 65 | req.ContentLength = 0 | |
| 66 | 66 | rec := httptest.NewRecorder() | |
| 67 | 67 | p.ServeHTTP(rec, req) | |
| @@ -80,17 +80,17 @@ func TestOnlyTheTwoEndpointsExist(t *testing.T) { | |||
| 80 | 80 | method, target string | |
| 81 | 81 | code int | |
| 82 | 82 | }{ | |
| 83 | {http.MethodGet, "/git/demo.git/info/refs?service=git-upload-pack", http.StatusOK}, | ||
| 84 | {http.MethodGet, "/git/demo.git/info/refs", http.StatusNotFound}, | ||
| 85 | {http.MethodGet, "/git/demo.git/info/refs?service=git-upload-pack&service=evil", http.StatusNotFound}, | ||
| 86 | {http.MethodGet, "/git/demo.git/git-upload-pack", http.StatusNotFound}, | ||
| 87 | {http.MethodPost, "/git/demo.git/info/refs?service=git-upload-pack", http.StatusNotFound}, | ||
| 88 | {http.MethodGet, "/git/demo.git/git-upload-pack/../../git-receive-pack", http.StatusNotFound}, | ||
| 89 | {http.MethodGet, "/git/demo.git/../demo.git/info/refs", http.StatusNotFound}, | ||
| 90 | {http.MethodGet, "/git/demo.git/git-upload-pack/objects/info/packs", http.StatusNotFound}, | ||
| 91 | {http.MethodGet, "/git/demo.git/objects/info/packs", http.StatusNotFound}, | ||
| 92 | {http.MethodGet, "/git/demo.git/HEAD", http.StatusNotFound}, | ||
| 93 | {http.MethodPost, "/git/demo.git/git-receive-pack", http.StatusForbidden}, | ||
| 83 | {http.MethodGet, "/demo.git/info/refs?service=git-upload-pack", http.StatusOK}, | ||
| 84 | {http.MethodGet, "/demo.git/info/refs", http.StatusNotFound}, | ||
| 85 | {http.MethodGet, "/demo.git/info/refs?service=git-upload-pack&service=evil", http.StatusNotFound}, | ||
| 86 | {http.MethodGet, "/demo.git/git-upload-pack", http.StatusNotFound}, | ||
| 87 | {http.MethodPost, "/demo.git/info/refs?service=git-upload-pack", http.StatusNotFound}, | ||
| 88 | {http.MethodGet, "/demo.git/git-upload-pack/../../git-receive-pack", http.StatusNotFound}, | ||
| 89 | {http.MethodGet, "/demo.git/../demo.git/info/refs", http.StatusNotFound}, | ||
| 90 | {http.MethodGet, "/demo.git/git-upload-pack/objects/info/packs", http.StatusNotFound}, | ||
| 91 | {http.MethodGet, "/demo.git/objects/info/packs", http.StatusNotFound}, | ||
| 92 | {http.MethodGet, "/demo.git/HEAD", http.StatusNotFound}, | ||
| 93 | {http.MethodPost, "/demo.git/git-receive-pack", http.StatusForbidden}, | ||
| 94 | 94 | } | |
| 95 | 95 | for _, c := range cases { | |
| 96 | 96 | req := httptest.NewRequest(c.method, c.target, nil) | |
| @@ -114,7 +114,7 @@ func TestConcurrentClonesAreBounded(t *testing.T) { | |||
| 114 | 114 | p.sem <- struct{}{} | |
| 115 | 115 | t.Cleanup(func() { <-p.sem }) | |
| 116 | 116 | ||
| 117 | req := httptest.NewRequest(http.MethodGet, "/git/demo.git/info/refs?service=git-upload-pack", nil) | ||
| 117 | req := httptest.NewRequest(http.MethodGet, "/demo.git/info/refs?service=git-upload-pack", nil) | ||
| 118 | 118 | rec := httptest.NewRecorder() | |
| 119 | 119 | p.ServeHTTP(rec, req) | |
| 120 | 120 | if rec.Code != http.StatusServiceUnavailable { | |
| @@ -137,7 +137,7 @@ func TestPerClientClonesAreBounded(t *testing.T) { | |||
| 137 | 137 | p.perClient[ip] = 1 | |
| 138 | 138 | p.mu.Unlock() | |
| 139 | 139 | ||
| 140 | req := httptest.NewRequest(http.MethodGet, "/git/demo.git/info/refs?service=git-upload-pack", nil) | ||
| 140 | req := httptest.NewRequest(http.MethodGet, "/demo.git/info/refs?service=git-upload-pack", nil) | ||
| 141 | 141 | rec := httptest.NewRecorder() | |
| 142 | 142 | p.ServeHTTP(rec, req) | |
| 143 | 143 | if rec.Code != http.StatusServiceUnavailable { | |
| @@ -179,7 +179,7 @@ func stalledFetch(t *testing.T, dir string) (*http.Request, func()) { | |||
| 179 | 179 | strings.NewReader("want "+sha+" side-band-64k ofs-delta agent=git/2.0\n"), | |
| 180 | 180 | pr, | |
| 181 | 181 | ) | |
| 182 | req := httptest.NewRequest(http.MethodPost, "/git/demo.git/git-upload-pack", pipeBody{r: body, c: pr}) | ||
| 182 | req := httptest.NewRequest(http.MethodPost, "/demo.git/git-upload-pack", pipeBody{r: body, c: pr}) | ||
| 183 | 183 | req.ContentLength = 4096 | |
| 184 | 184 | req.Header.Set("Content-Type", "application/x-git-upload-pack-request") | |
| 185 | 185 | return req, func() { pw.Close() } | |