xonecas.io
8356
Wx

www-xonecas-io / commit 3219a18

clone box shows the site's own URL, and the build serves each repo for dumb-HTTP clones (1015)

Co-Authored-By: Claude Opus 5.5

Sean Caetano Martin2026-11-08 3219a18786eea17f7b9d44b6a83f1ddcadb83cc1 parent 9b5bd25

6 files changed

internal/site/build.go+3−0
@@ -67,6 +67,9 @@ func Build(projects []project.Project, out, tailwind string) error {
6767 if err := writeCommits(out, p, rows[i], fresh); err != nil {
6868 return fmt.Errorf("%s: %w", p.Name, err)
6969 }
70+ if err := writeClone(out, p.Name, p.Sources[0].Dir); err != nil {
71+ return fmt.Errorf("%s: %w", p.Name, err)
72+ }
7073 }
7174 if err := os.WriteFile(filepath.Join(out, ".stamp"), []byte(stamp), 0o644); err != nil {
7275 return err
internal/site/build_test.go+1−1
@@ -69,7 +69,7 @@ func TestBuild(t *testing.T) {
6969 t.Fatal(err)
7070 }
7171 for _, want := range []string{`<h1 id="hello">Hello</h1>`, `src="/projects/hello/raw/img/logo.png"`, `href="/projects/hello/tree/docs/"`,
72- `href="/projects/hello/blob/docs/guide.md/#top"`, `href="https://x.io"`, `git clone https://github.com/xonecas/hello.git`} {
72+ `href="/projects/hello/blob/docs/guide.md/#top"`, `href="https://x.io"`, `git clone https://xonecas.io/hello.git`} {
7373 if !strings.Contains(string(page), want) {
7474 t.Errorf("projects/hello/index.html is missing %q", want)
7575 }
internal/site/clone.go+21−0
@@ -0,0 +1,21 @@
1+package site
2+
3+import (
4+ "fmt"
5+ "os"
6+ "os/exec"
7+ "path/filepath"
8+)
9+
10+// writeClone writes /<name>.git, a bare copy of the project's repo that any static server can serve
11+// to `git clone` over git's dumb HTTP protocol. A local clone hard-links its objects, so it costs little disk.
12+func writeClone(out, name, dir string) error {
13+ dest := filepath.Join(out, name+".git")
14+ if err := os.RemoveAll(dest); err != nil {
15+ return err
16+ }
17+ if out, err := exec.Command("git", "clone", "--bare", "--quiet", dir, dest).CombinedOutput(); err != nil {
18+ return fmt.Errorf("git clone: %w: %s", err, out)
19+ }
20+ return exec.Command("git", "--git-dir", dest, "update-server-info").Run()
21+}
internal/site/clone_test.go+27−0
@@ -0,0 +1,27 @@
1+package site
2+
3+import (
4+ "net/http"
5+ "net/http/httptest"
6+ "os"
7+ "os/exec"
8+ "path/filepath"
9+ "testing"
10+)
11+
12+// TestClone clones a written repo from a plain static file server, as a visitor would.
13+func TestClone(t *testing.T) {
14+ out := t.TempDir()
15+ if err := writeClone(out, "hello", gitRepo(t)); err != nil {
16+ t.Fatal(err)
17+ }
18+ srv := httptest.NewServer(http.FileServer(http.Dir(out)))
19+ defer srv.Close()
20+ dest := filepath.Join(t.TempDir(), "hello")
21+ if b, err := exec.Command("git", "clone", "--quiet", srv.URL+"/hello.git", dest).CombinedOutput(); err != nil {
22+ t.Fatal(string(b))
23+ }
24+ if _, err := os.Stat(filepath.Join(dest, "docs/guide.md")); err != nil {
25+ t.Error("the clone has no docs/guide.md")
26+ }
27+}
internal/site/templates/project.html+1−1
@@ -37,7 +37,7 @@
3737 </section>
3838 <section>
3939 <h2 class="font-bold border-b-[3px] border-ink pb-1 mb-2">Clone</h2>
40- <pre class="bg-pre text-pre-fg rounded-[2px] px-4 py-3 font-mono text-[12.5px] whitespace-pre-wrap break-all select-all">git clone {{(index .P.Sources 0).URL}}</pre>
40+ <pre class="bg-pre text-pre-fg rounded-[2px] px-4 py-3 font-mono text-[12.5px] whitespace-pre-wrap break-all select-all">git clone https://xonecas.io/{{.P.Name}}.git</pre>
4141 </section>
4242 </aside>
4343 </div>
tickets/1015-remotes-show-github-should-show-correctly-from.md+13−3
@@ -2,13 +2,13 @@
22 id: 1015
33 title: Remotes show github, should show correctly, from the site's repos remotes.
44 type: bug
5-status: blocked
5+status: review
66 priority: p2
77 created: 2026-11-08T03:48:13Z
8-updated: 2026-11-08T04:04:19Z
8+updated: 2026-11-08T04:09:42Z
99 source: devnote
1010 area: site
11-moves: 2026-11-08T04:02:21Z inbox doing drag; 2026-11-08T04:04:19Z doing blocked agent
11+moves: 2026-11-08T04:02:21Z inbox doing drag; 2026-11-08T04:04:19Z doing blocked agent; 2026-11-08T04:07:25Z blocked doing agent; 2026-11-08T04:09:42Z doing review agent
1212 ---
1313
1414 ## Context
@@ -33,3 +33,13 @@ Filed from `http://192.168.122.10:8080/projects/dotfiles/`, on `pre.bg-pre.text-
3333 (c) Keep the upstream URL until hosting is decided.
3434
3535 I recommend (b): it is the only one where the URL on the page is real. Also tell me the URL shape you want, e.g. https://xonecas.io/<name>.git or https://xonecas.io/projects/<name>.git.
36+
37+- 2026-11-08 04:09Z (agent): Done, with option (b) as recommended, since you asked me to decide. Clone now shows 'git clone https://xonecas.io/<name>.git', and that URL works from any static server.
38+
39+ - internal/site/clone.go (new): writeClone puts a bare copy of each shown project's repo at public/<name>.git ('git clone --bare' from the store, then 'git update-server-info'), so git's dumb HTTP protocol can clone it with no git server.
40+ - build.go calls it per project; project.html prints the site URL; the Sources list still links the upstreams.
41+ - clone_test.go: builds a repo, serves it with a plain http.FileServer, and runs a real 'git clone' against it.
42+
43+ CHECKED: go vet, go test pass. Full build: 82 public/<name>.git. From the dev server: 'git clone http://192.168.122.10:8080/irvc.git' and dotfiles.git both clone (dotfiles: 99 commits). The local clone hard-links objects (pack link count 2), and disk use did not change. A rebuild with no changes takes 5.4s.
44+
45+ NOT CHECKED / WATCH OUT: (1) Off this disk, e.g. rsync to the VPS, public/ carries the full repos, about 351 MB today. (2) A project that becomes hidden keeps its old public/<name>.git until public/ is wiped. The build does not prune; I did not check whether old HTML pages behave the same. (3) Nothing serves xonecas.io yet (1011), so the printed URL works only once public/ is hosted there.