Commit f82dd00118
Verified · cmc
Layout: unified · split
e2e/design_test.go +6
| @@ -348,6 +348,8 @@ func TestTreeSearchCodeAndClone(t *testing.T) { | |||
| 348 | mustGit(t, work, env, "clone", inst.sshURL("alice/app"), "w") | 348 | mustGit(t, work, env, "clone", inst.sshURL("alice/app"), "w") |
| 349 | dir := filepath.Join(work, "w") | 349 | dir := filepath.Join(work, "w") |
| 350 | os.WriteFile(filepath.Join(dir, "README.md"), []byte("# app\n"), 0o644) | 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 | mustGit(t, dir, env, "checkout", "-q", "-b", "main") | 353 | mustGit(t, dir, env, "checkout", "-q", "-b", "main") |
| 352 | mustGit(t, dir, env, "add", ".") | 354 | mustGit(t, dir, env, "add", ".") |
| 353 | mustGit(t, dir, env, "commit", "-q", "-m", "init") | 355 | mustGit(t, dir, env, "commit", "-q", "-m", "init") |
| @@ -362,4 +364,8 @@ func TestTreeSearchCodeAndClone(t *testing.T) { | |||
| 362 | if !strings.Contains(body, `<label>SSH</label>`) || !strings.Contains(body, `<label>HTTPS</label>`) { | 364 | if !strings.Contains(body, `<label>SSH</label>`) || !strings.Contains(body, `<label>HTTPS</label>`) { |
| 363 | t.Error("clone blocks are not labelled") | 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 | <div class="cardhead"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/blob/{{.Ref}}/{{.Prefix}}{{.ReadmeName}}">{{.ReadmeName}}</a></div> | 29 | <div class="cardhead"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/blob/{{.Ref}}/{{.Prefix}}{{.ReadmeName}}">{{.ReadmeName}}</a></div> |
| 30 | <div class="rendered">{{.ReadmeHTML}}</div> | 30 | <div class="rendered">{{.ReadmeHTML}}</div> |
| 31 | </section>{{end}} | 31 | </section>{{end}} |
| 32 | {{if .Entries}}<div class="facts"> | 32 | {{if and .Entries (not .DirPath)}}<div class="facts"> |
| 33 | <div class="clone"> | 33 | <div class="clone"> |
| 34 | <h2>Clone</h2> | 34 | <h2>Clone</h2> |
| 35 | <label>SSH</label><pre><code>git clone {{.SSHCloneURL}}</code></pre> | 35 | <label>SSH</label><pre><code>git clone {{.SSHCloneURL}}</code></pre> |