vole
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software: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 · 9h 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/web/transport_test.go +8−8
| @@ -46,11 +46,11 @@ func TestSSHURLUsesTheConfiguredHost(t *testing.T) { | |||
| 46 | 46 | func TestCloneURLPrefersTheConfiguredOrigin(t *testing.T) { | |
| 47 | 47 | t.Parallel() | |
| 48 | 48 | w := &Web{Cfg: &config.Config{PublicURL: "https://forge.example.com"}} | |
| 49 | r := httptest.NewRequest("GET", "http://internal:8080/r/demo", nil) | ||
| 49 | r := httptest.NewRequest("GET", "http://internal:8080/demo", nil) | ||
| 50 | 50 | r.Host = "evil.example" | |
| 51 | 51 | r.Header.Set("X-Forwarded-Proto", "http") | |
| 52 | 52 | r.Header.Set("X-Forwarded-Host", "evil.example") | |
| 53 | if got, want := w.cloneURL(r, "demo"), "https://forge.example.com/git/demo.git"; got != want { | ||
| 53 | if got, want := w.cloneURL(r, "demo"), "https://forge.example.com/demo.git"; got != want { | ||
| 54 | 54 | t.Fatalf("cloneURL = %q, want %q", got, want) | |
| 55 | 55 | } | |
| 56 | 56 | } | |
| @@ -59,16 +59,16 @@ func TestCloneURLPrefersTheConfiguredOrigin(t *testing.T) { | |||
| 59 | 59 | // believed when the instance says a proxy is in front of it. | |
| 60 | 60 | func TestCloneURLFallsBackToTheRequestOrigin(t *testing.T) { | |
| 61 | 61 | t.Parallel() | |
| 62 | r := httptest.NewRequest("GET", "http://127.0.0.1:8080/r/demo", nil) | ||
| 62 | r := httptest.NewRequest("GET", "http://127.0.0.1:8080/demo", nil) | ||
| 63 | 63 | r.Host = "127.0.0.1:8080" | |
| 64 | 64 | r.Header.Set("X-Forwarded-Proto", "https") | |
| 65 | 65 | ||
| 66 | 66 | w := &Web{Cfg: &config.Config{}} | |
| 67 | if got, want := w.cloneURL(r, "demo"), "http://127.0.0.1:8080/git/demo.git"; got != want { | ||
| 67 | if got, want := w.cloneURL(r, "demo"), "http://127.0.0.1:8080/demo.git"; got != want { | ||
| 68 | 68 | t.Fatalf("cloneURL without a proxy = %q, want %q", got, want) | |
| 69 | 69 | } | |
| 70 | 70 | w = &Web{Cfg: &config.Config{GitHTTPClientIPHeader: "X-Forwarded-For"}} | |
| 71 | if got, want := w.cloneURL(r, "demo"), "https://127.0.0.1:8080/git/demo.git"; got != want { | ||
| 71 | if got, want := w.cloneURL(r, "demo"), "https://127.0.0.1:8080/demo.git"; got != want { | ||
| 72 | 72 | t.Fatalf("cloneURL behind a declared proxy = %q, want %q", got, want) | |
| 73 | 73 | } | |
| 74 | 74 | } | |
| @@ -127,12 +127,12 @@ func TestSecurityHeadersCloseTheSurface(t *testing.T) { | |||
| 127 | 127 | func TestGitSlotRefusesWhenSaturated(t *testing.T) { | |
| 128 | 128 | t.Parallel() | |
| 129 | 129 | w := &Web{Cfg: &config.Config{}, gitSem: make(chan struct{}, 1), gitWait: 20 * time.Millisecond} | |
| 130 | release, ok := w.gitSlot(httptest.NewRecorder(), httptest.NewRequest("GET", "/r/demo/search", nil)) | ||
| 130 | release, ok := w.gitSlot(httptest.NewRecorder(), httptest.NewRequest("GET", "/demo/search", nil)) | ||
| 131 | 131 | if !ok { | |
| 132 | 132 | t.Fatal("the first page could not take a slot") | |
| 133 | 133 | } | |
| 134 | 134 | rw := httptest.NewRecorder() | |
| 135 | if _, ok := w.gitSlot(rw, httptest.NewRequest("GET", "/r/demo/search", nil)); ok { | ||
| 135 | if _, ok := w.gitSlot(rw, httptest.NewRequest("GET", "/demo/search", nil)); ok { | ||
| 136 | 136 | t.Fatal("a page past the pool was accepted") | |
| 137 | 137 | } | |
| 138 | 138 | if rw.Code != http.StatusServiceUnavailable { | |
| @@ -142,7 +142,7 @@ func TestGitSlotRefusesWhenSaturated(t *testing.T) { | |||
| 142 | 142 | t.Fatal("a busy answer without Retry-After") | |
| 143 | 143 | } | |
| 144 | 144 | release() | |
| 145 | if _, ok := w.gitSlot(httptest.NewRecorder(), httptest.NewRequest("GET", "/r/demo/search", nil)); !ok { | ||
| 145 | if _, ok := w.gitSlot(httptest.NewRecorder(), httptest.NewRequest("GET", "/demo/search", nil)); !ok { | ||
| 146 | 146 | t.Fatal("a released slot was not reusable") | |
| 147 | 147 | } | |
| 148 | 148 | } | |