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) { |
| 348 | 348 | mustGit(t, work, env, "clone", inst.sshURL("alice/app"), "w") |
| 349 | 349 | dir := filepath.Join(work, "w") |
| 350 | 350 | 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) |
| 351 | 353 | mustGit(t, dir, env, "checkout", "-q", "-b", "main") |
| 352 | 354 | mustGit(t, dir, env, "add", ".") |
| 353 | 355 | mustGit(t, dir, env, "commit", "-q", "-m", "init") |
| @@ -362,4 +364,8 @@ func TestTreeSearchCodeAndClone(t *testing.T) { |
| 362 | 364 | if !strings.Contains(body, `<label>SSH</label>`) || !strings.Contains(body, `<label>HTTPS</label>`) { |
| 363 | 365 | t.Error("clone blocks are not labelled") |
| 364 | 366 | } |
| 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 | } |
| 365 | 371 | } |
internal/web/templates/tree.html
+1 −1
| @@ -29,7 +29,7 @@ |
| 29 | 29 | <div class="cardhead"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/blob/{{.Ref}}/{{.Prefix}}{{.ReadmeName}}">{{.ReadmeName}}</a></div> |
| 30 | 30 | <div class="rendered">{{.ReadmeHTML}}</div> |
| 31 | 31 | </section>{{end}} |
| 32 | | {{if .Entries}}<div class="facts"> |
| 32 | {{if and .Entries (not .DirPath)}}<div class="facts"> |
| 33 | 33 | <div class="clone"> |
| 34 | 34 | <h2>Clone</h2> |
| 35 | 35 | <label>SSH</label><pre><code>git clone {{.SSHCloneURL}}</code></pre> |