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/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

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

Record the default branch summary when a push lands

8dc56e4e258dd56e2c20776f80d61dbed4993f31 · Keenan Nemetz · 10d ago · parent 20442b59

Record the default branch summary when a push lands

The landing card showed the default branch tip and the language it is
mostly made of by running `symbolic-ref`, `rev-parse`, `log -1` and
`ls-tree -r` per repository on every home page read. Those facts change
only when a push moves the branch, so the push now records them.

- `repos` carries head_sha, head_subject, head_author, head_when,
  language and lang_class, and `Index.Entry` returns them with the rest of
  the row.
- `Store.RefreshHead` recomputes the summary and skips the tree walk when
  the recorded tip is still the branch tip, so a metadata or tag push
  costs one rev-parse. It runs from post-receive, from the rebuild, and
  after the default branch changes in settings.
- The language mapping moved to `internal/lang`, shared by the web pages
  and the summary; `fileClass` and `languageFor` are now one table.
- The home cards read the head, language, counts, ACL and newest event
  time from the index. The home page starts no git process at all; the
  all-git card builder stays as the fallback for a Web without an index.

Load harness at concurrency 4 with three repositories: home goes from 243
to 749 req/s, p50 from 16 ms to 5 ms, and the server runs no git child
process for those requests.

server/web/file_icons.go −51

@@ -37,54 +37,3 @@ func fileIcon(name string) string {
37 37 }
38 38 return "file"
39 39 }
40
41 func fileClass(name string) string {
42 ext := strings.ToLower(path.Ext(name))
43 switch ext {
44 case ".go":
45 return "lang-go"
46 case ".rs":
47 return "lang-rust"
48 case ".js", ".mjs", ".cjs", ".jsx":
49 return "lang-js"
50 case ".ts", ".tsx":
51 return "lang-ts"
52 case ".py":
53 return "lang-py"
54 case ".rb":
55 return "lang-rb"
56 case ".java", ".kt", ".scala":
57 return "lang-jvm"
58 case ".c", ".h":
59 return "lang-c"
60 case ".cc", ".cpp", ".cxx", ".hpp":
61 return "lang-cpp"
62 case ".cs":
63 return "lang-cs"
64 case ".php":
65 return "lang-php"
66 case ".sh", ".bash", ".zsh", ".fish":
67 return "lang-sh"
68 case ".html", ".htm":
69 return "lang-html"
70 case ".css", ".scss", ".sass":
71 return "lang-css"
72 case ".json", ".yaml", ".yml", ".toml", ".ini", ".xml", ".conf":
73 return "lang-config"
74 case ".md", ".markdown", ".mdown", ".mkd", ".txt", ".rst":
75 return "lang-text"
76 case ".sql":
77 return "lang-sql"
78 case ".png", ".jpg", ".jpeg", ".gif", ".svg", ".webp", ".ico":
79 return "lang-image"
80 case ".lock":
81 return "lang-lock"
82 }
83 switch strings.ToLower(name) {
84 case "dockerfile", "containerfile", "makefile", "makefile.am", "cmakelists.txt":
85 return "lang-build"
86 case "go.mod", "go.sum":
87 return "lang-go"
88 }
89 return ""
90 }