xonecas.io
8356
Wx

www-xonecas-io / commit c96c23d

site remote takes a local repo or any https host, so a repo needs no other home (1042)

Co-Authored-By: Claude Opus 5.5

Sean Caetano Martin2026-11-08 c96c23daed018b86b8448004b56dea707379796d parent 7414053

10 files changed

cmd/site/main.go+1−1
@@ -1,7 +1,7 @@
11 // Command site builds xonecas.io from bare git repos and serves it locally.
22 //
33 // site import [-sources sources.txt] [-store repos] [-jobs 8] [-meta data/meta.json]
4-// site remote [-sources sources.txt] [-store repos] [-meta data/meta.json] list | add <url> | rm <url>
4+// site remote [-sources sources.txt] [-store repos] [-meta data/meta.json] list | add <url or path> | rm <url or path>
55 // site index [-sources sources.txt] [-store repos] [-overrides overrides.txt] [-meta data/meta.json] [-out data/projects.json]
66 // site build [-data data/projects.json] [-out public] [-tailwind bin/tailwindcss]
77 // site serve [-dir public] [-addr :8080]
cmd/site/remote.go+1−1
@@ -24,7 +24,7 @@ func remote(args []string, sources, root, meta string) error {
2424 return nil
2525 }
2626 if len(args) != 2 || (args[0] != "add" && args[0] != "rm") {
27- return errors.New("usage: site remote list | add <url> | rm <url>")
27+ return errors.New("usage: site remote list | add <url or path> | rm <url or path>")
2828 }
2929 url, err := store.Clean(args[1])
3030 if err != nil {
internal/site/build.go+6−1
@@ -36,7 +36,12 @@ var funcs = template.FuncMap{
3636 "inc": func(i int) int { return i + 1 },
3737 "maxDiff": func() int { return MaxDiffLines },
3838 "dec": func(i int) int { return i - 1 },
39- "web": func(url string) string { return strings.TrimSuffix(strings.TrimPrefix(url, "https://"), ".git") },
39+ "web": func(url string) string { // "" for a local repo, which has no other home
40+ if !strings.HasPrefix(url, "https://") {
41+ return ""
42+ }
43+ return strings.TrimSuffix(strings.TrimPrefix(url, "https://"), ".git")
44+ },
4045 "dict": func(kv ...any) (map[string]any, error) {
4146 if len(kv)%2 != 0 {
4247 return nil, errors.New("dict needs key, value pairs")
internal/site/templates/project.html+1−1
@@ -32,7 +32,7 @@
3232 <section>
3333 <h2 class="font-bold border-b-[3px] border-edge pb-1 mb-2">Sources</h2>
3434 {{range .P.Sources}}<div class="py-1.5 border-b border-line">
35- <a href="https://{{web .URL}}" class="font-semibold break-all">{{web .URL}}</a>
35+ {{with web .URL}}<a href="https://{{.}}" class="font-semibold break-all">{{.}}</a>{{else}}<b class="font-semibold">Hosted here</b>{{end}}
3636 <div class="text-soft">{{.Branch}} · {{.Commits}} commits</div>
3737 </div>{{end}}
3838 </section>
internal/store/meta.go+2−2
@@ -13,7 +13,7 @@ type Meta struct {
1313 Description string `json:"description"`
1414 }
1515
16-// FetchMeta lists the public repos of every GitHub and GitLab owner in urls, keyed by clone URL.
16+// FetchMeta lists the public repos of every GitHub and GitLab owner in urls, keyed by clone URL. Other sources have none.
1717 // That is one request per owner, well inside GitHub's 60 unauthenticated requests an hour.
1818 func FetchMeta(urls []string) (map[string]Meta, error) {
1919 owners := map[string]bool{}
@@ -27,7 +27,7 @@ func FetchMeta(urls []string) (map[string]Meta, error) {
2727 host, owner, _ := strings.Cut(o, "/")
2828 api := ownerAPI(host, owner)
2929 if api == "" {
30- return nil, fmt.Errorf("no API for %s", host)
30+ continue // a local repo or another host: the README describes it
3131 }
3232 var rows []struct {
3333 CloneURL string `json:"clone_url"`
internal/store/sources.go+17−10
@@ -5,6 +5,7 @@ import (
55 "errors"
66 "fmt"
77 "os"
8+ "path/filepath"
89 "slices"
910 "strings"
1011 )
@@ -25,18 +26,24 @@ func Sources(path string) ([]string, error) {
2526 return urls, err
2627 }
2728
28-// Clean checks that url is an https clone URL on a host import can describe, and returns it ending in .git.
29-func Clean(url string) (string, error) {
30- rest, ok := strings.CutPrefix(url, "https://")
31- host, path, _ := strings.Cut(rest, "/")
32- owner, name, _ := strings.Cut(strings.TrimSuffix(strings.TrimSuffix(path, "/"), ".git"), "/")
33- if !ok || owner == "" || name == "" || strings.Contains(name, "/") {
34- return "", fmt.Errorf("%s is not a clone URL like https://github.com/owner/name.git", url)
29+// Clean returns a source as the sources file keeps it: an https clone URL ending in .git,
30+// or the absolute path of a local git repo, for a repo that lives nowhere else.
31+func Clean(src string) (string, error) {
32+ if rest, ok := strings.CutPrefix(src, "https://"); ok {
33+ host, path, _ := strings.Cut(strings.TrimSuffix(strings.TrimSuffix(rest, "/"), ".git"), "/")
34+ if host == "" || !strings.Contains(path, "/") {
35+ return "", fmt.Errorf("%s is not a clone URL like https://host/owner/name.git", src)
36+ }
37+ return "https://" + host + "/" + path + ".git", nil
38+ }
39+ dir, err := filepath.Abs(src)
40+ if err == nil {
41+ _, err = git("-C", dir, "rev-parse", "--git-dir")
3542 }
36- if ownerAPI(host, owner) == "" {
37- return "", fmt.Errorf("%s: import can only describe github.com and gitlab.com remotes", url)
43+ if err != nil {
44+ return "", fmt.Errorf("%s is neither an https clone URL nor a local git repo", src)
3845 }
39- return "https://" + host + "/" + owner + "/" + name + ".git", nil
46+ return dir, nil
4047 }
4148
4249 // AddSource appends url to the sources file at path, unless it is there already.
internal/store/store_test.go+5−2
@@ -55,9 +55,12 @@ func TestSources(t *testing.T) {
5555 }
5656
5757 func TestEditSources(t *testing.T) {
58+ local := t.TempDir()
59+ exec.Command("git", "init", "-q", local).Run()
5860 for in, want := range map[string]string{
59- "https://github.com/x/a": "https://github.com/x/a.git", "https://gitlab.com/x/b.git/": "https://gitlab.com/x/b.git",
60- "https://codeberg.org/x/c.git": "", "git@github.com:x/a.git": "", "https://github.com/x": "", "https://gitlab.com/g/sub/d.git": "",
61+ "https://github.com/x/a": "https://github.com/x/a.git", "https://gitlab.com/g/sub/b.git/": "https://gitlab.com/g/sub/b.git",
62+ "https://codeberg.org/x/c.git": "https://codeberg.org/x/c.git", local + "/": local,
63+ "git@github.com:x/a.git": "", "https://github.com/x": "", t.TempDir(): "",
6164 } {
6265 if got, _ := Clean(in); got != want {
6366 t.Errorf("Clean(%q) = %q, want %q", in, got, want)
sources.txt+1−1
@@ -1,4 +1,4 @@
1-# Every public remote the site imports, one clone URL per line. Codeberg is left out: it holds only copies.
1+# Every repo the site imports, one per line: a public https clone URL, or the path of a local repo that lives only here. Codeberg is left out: it holds only copies. Edit with bin/site remote add|rm.
22 https://github.com/sacenox/alfred.git
33 https://github.com/sacenox/awesome-ai-tools.git
44 https://github.com/sacenox/awesome-cli-apps.git
tickets/1042-how-do-we-add-new-remotes.md+20−2
@@ -5,9 +5,9 @@ type: feature
55 status: review
66 priority: p2
77 created: 2026-11-08T06:26:18Z
8-updated: 2026-11-08T07:00:33Z
8+updated: 2026-11-08T07:04:04Z
99 source: human
10-moves: 2026-11-08T06:26:22Z inbox doing drag; 2026-11-08T06:27:05Z doing review agent; 2026-11-08T06:57:08Z review doing drag; 2026-11-08T07:00:33Z doing review agent
10+moves: 2026-11-08T06:26:22Z inbox doing drag; 2026-11-08T06:27:05Z doing review agent; 2026-11-08T06:57:08Z review doing drag; 2026-11-08T07:00:33Z doing review agent; 2026-11-08T07:01:42Z review todo note; 2026-11-08T07:01:44Z todo doing drag; 2026-11-08T07:04:04Z doing review agent
1111 area: import
1212 ---
1313
@@ -34,3 +34,21 @@ Can we make this more formal, like a cli with the server bin? We could build on
3434 Code: cmd/site/remote.go (the command, and importAll, which import now shares); internal/store/sources.go (Sources moved there from store.go, plus Clean, AddSource and RemoveSource); meta.go's host table became ownerAPI(), which Clean uses too. To grow it later, the next commands (pin, public/private) can sit beside remote in cmd/site and edit overrides.txt the same way.
3535 Checked: go vet and go test (new TestEditSources); a real add then rm of github.com/octocat/Hello-World on scratch copies of sources.txt, repos/ and meta.json (mirrored, description fetched, sources.txt back byte-identical after rm); a failed add of a missing repo leaves sources.txt unchanged and no mirror; the error messages for usage, codeberg and a duplicate. Not run: a full make import against all 105 remotes. Its path is the same importAll that the add test ran. Your real sources.txt, rep …
3636 Correction to my first note: an owner with 100 or more repos doesn't silently lose descriptions; FetchMeta stops with "100 repos, the list needs paging".
37+
38+- 2026-11-08 07:01Z (human): This doesn't work, it needs me to add the repo to another website first. Stop wasting my time, think before you act, this is my github replacement. I'm tired of repeating this.
39+
40+- 2026-11-08 07:02Z (human): I want to be able to git push with ssh, how is that not fucking obvious?
41+
42+- 2026-11-08 07:04Z (agent): You're right: add only took GitHub/GitLab URLs, so a repo had to exist elsewhere first. Fixed, and the site is now the repo's home:
43+ bin/site remote add ~/repos/my-thing a local git repo, no remote needed; mirrored from that path
44+ bin/site remote add https://any.host/o/r any https host; GitHub/GitLab still give descriptions, the rest use the README summary
45+ bin/site remote rm <path or url>
46+ Then make index build, and it clones from xonecas.io/<name>.git like the rest.
47+ Changes:
48+ - store.Clean accepts an existing local git repo (kept as its absolute path) or any https clone URL.
49+ - FetchMeta skips sources with no host API instead of failing the whole import.
50+ - On the project page, a local source shows 'Hosted here' instead of a broken https link.
51+ - The sources.txt header and the usage text mention paths.
52+ Checked: go vet and go test (Clean cases for a local repo, codeberg, nested gitlab, ssh, a non-repo dir). End to end on scratch copies: remote add . mirrored this repo by path, index made it a shown project (45 commits; no README, so no description), build rendered its page with 'Hosted here', and rm removed the line and the mirror. A failed add on another host rolled back.
53+ Not done: this repo isn't added to the real sources.txt. That is 1041, still in inbox with its question about tickets/ being public.
54+ Found, filed and not fixed: every published <name>.git/config holds the build machine's mirror path (/home/sacenox/...), for GitHub projects too; see the new inbox bug.
tickets/1043-published-clones-expose-the-build-machine-s.md+13−0
@@ -0,0 +1,13 @@
1+---
2+id: 1043
3+title: Published clones expose the build machine's mirror path in <name>.git/config
4+type: bug
5+status: inbox
6+priority: p2
7+area: site
8+created: 2026-11-08T07:04:04Z
9+updated: 2026-11-08T07:04:04Z
10+source: agent
11+---
12+
13+Seen while testing 1042: writeClone (internal/site/clone.go) runs git clone --bare from the mirror, so every public/<name>.git/config keeps [remote "origin"] url = <absolute path of the mirror under repos/>, e.g. /home/sacenox/repos/www-xonecas-io/repos/github.com/... Anyone can fetch https://xonecas.io/<name>.git/config and read it. Seen in a scratch build. I did not check the live site or the other files in the clone (packed-refs, FETCH_HEAD).