Commit f82dd00118

f82dd00118b0d54238724ffcb1dde2a2a39acbf1

parent: 7756246a08

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-17 16:08 UTC

web: clone and facts on the repository root only

Ref #218
e2e/design_test.go +6
@@ -348,6 +348,8 @@ func TestTreeSearchCodeAndClone(t *testing.T) {
348348 mustGit(t, work, env, "clone", inst.sshURL("alice/app"), "w")
349349 dir := filepath.Join(work, "w")
350350 os.WriteFile(filepath.Join(dir, "README.md"), []byte("# app\n"), 0o644)
351 os.MkdirAll(filepath.Join(dir, "docs"), 0o755)
352 os.WriteFile(filepath.Join(dir, "docs", "README.md"), []byte("# docs\n"), 0o644)
351353 mustGit(t, dir, env, "checkout", "-q", "-b", "main")
352354 mustGit(t, dir, env, "add", ".")
353355 mustGit(t, dir, env, "commit", "-q", "-m", "init")
@@ -362,4 +364,8 @@ func TestTreeSearchCodeAndClone(t *testing.T) {
362364 if !strings.Contains(body, `<label>SSH</label>`) || !strings.Contains(body, `<label>HTTPS</label>`) {
363365 t.Error("clone blocks are not labelled")
364366 }
367 // Clone and about belong to the repository root, not a subdirectory.
368 if _, sub := inst.get(t, "/alice/app/tree/main/docs"); strings.Contains(sub, `<div class="facts">`) {
369 t.Error("subdirectory listing still shows the clone/about facts block")
370 }
365371}
internal/web/templates/tree.html +1 −1
@@ -29,7 +29,7 @@
2929<div class="cardhead"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/blob/{{.Ref}}/{{.Prefix}}{{.ReadmeName}}">{{.ReadmeName}}</a></div>
3030<div class="rendered">{{.ReadmeHTML}}</div>
3131</section>{{end}}
32{{if .Entries}}<div class="facts">
32{{if and .Entries (not .DirPath)}}<div class="facts">
3333 <div class="clone">
3434 <h2>Clone</h2>
3535 <label>SSH</label><pre><code>git clone {{.SSHCloneURL}}</code></pre>