Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Code

392 commit(s) on main

Merge change request 01M70WES5ZZDJ6RP226WB11BBZ: Let people rename and remove their own passkeys keenan · 1h ago 4b8c9e1d
history blame raw 1.8 KiB
1package server_test
2
3import (
4 "os"
5 "path/filepath"
6 "strings"
7 "testing"
8)
9
10func TestFileHistoryAndBlame(t *testing.T) {
11 t.Parallel()
12 f := newFixture(t)
13 f.publish(f.repo)
14 work := workRepo(t, map[string]string{"readme.md": "v1 line\nkeep me\n"})
15 if _, errs, err := f.git(work, "push", f.sshURL(f.repo), "main:refs/heads/main"); err != nil {
16 t.Fatalf("initial push: %s", errs)
17 }
18 if err := os.WriteFile(filepath.Join(work, "readme.md"), []byte("v2 line\nkeep me\nbrand new\n"), 0o644); err != nil {
19 t.Fatal(err)
20 }
21 if _, errs, err := runGit(t, work, "commit", "-qam", "change the readme"); err != nil {
22 t.Fatalf("commit: %s", errs)
23 }
24 if _, errs, err := f.git(work, "push", f.sshURL(f.repo), "main:refs/heads/main"); err != nil {
25 t.Fatalf("second push: %s", errs)
26 }
27
28 code, body := f.get("/" + f.repo + "/commits/main/readme.md")
29 if code != 200 {
30 t.Fatalf("history = %d", code)
31 }
32 for _, want := range []string{"readme.md", "change the readme", "initial"} {
33 if !strings.Contains(body, want) {
34 t.Fatalf("history does not show %q:\n%s", want, body)
35 }
36 }
37
38 code, body = f.get("/" + f.repo + "/blame/main/readme.md")
39 if code != 200 {
40 t.Fatalf("blame = %d", code)
41 }
42 for _, want := range []string{"v2 line", "brand new", "keep me", "t"} {
43 if !strings.Contains(body, want) {
44 t.Fatalf("blame does not show %q:\n%s", want, body)
45 }
46 }
47
48 if code, body := f.get("/" + f.repo + "/blob/main/readme.md"); code != 200 || !strings.Contains(body, "/blame/main/readme.md") || !strings.Contains(body, "/commits/main/readme.md") {
49 t.Fatalf("blob page has no history/blame links: %d\n%s", code, body)
50 }
51 if code, _ := f.get("/" + f.repo + "/commits/main/nope.md"); code != 404 {
52 t.Fatalf("unknown file history = %d, want 404", code)
53 }
54 if code, _ := f.get("/" + f.repo + "/blame/main/nope.md"); code != 404 {
55 t.Fatalf("unknown blame = %d, want 404", code)
56 }
57}
58