summaryrefslogtreecommitdiff
path: root/vrsite/static.go
diff options
context:
space:
mode:
Diffstat (limited to 'vrsite/static.go')
-rw-r--r--vrsite/static.go50
1 files changed, 38 insertions, 12 deletions
diff --git a/vrsite/static.go b/vrsite/static.go
index e4970c6..7d31b1d 100644
--- a/vrsite/static.go
+++ b/vrsite/static.go
@@ -33,20 +33,32 @@ func run(dir string, name string, args ...string) []byte {
func buildSite(logPath, repoAbs, out, title string, theme, light *Theme) {
start := time.Now()
- site := buildModel(title, readLog(logPath))
- site.Theme, site.Light, site.Repo = theme, light, repoAbs
- if site.Change == "" {
+ entries := readLog(logPath)
+ ranked := buildModel(title, entries, "").Ranked
+ if len(ranked) == 0 {
fatal("log has no jj change ids")
}
-
- // every file in the repo at the site change; content comes from one
- // git archive of the commit instead of a jj spawn per file
- list, err := jjRun(repoAbs, "file", "list", "-r", site.Change)
- if err != nil {
- fmt.Fprintln(os.Stderr, err)
- fatal("change %s is not in %s — logs are per repository; point -repo at the one the trace was recorded in", short(site.Change), repoAbs)
+ // the most-logged change this repo actually has: a log can span repos, and
+ // the busiest change in it may belong to another one
+ var change string
+ var list []byte
+ for _, c := range ranked {
+ out, err := jjRun(repoAbs, "file", "list", "-r", c)
+ if err == nil {
+ change, list = c, out
+ break
+ }
}
- site.All = site.filesAt(strings.Split(strings.TrimRight(string(list), "\n"), "\n"), site.Change)
+ if change == "" {
+ fatal("none of the log's %d changes are in %s — logs are per repository; point -repo at the one the trace was recorded in",
+ len(ranked), repoAbs)
+ }
+ // an export is a picture of one change, so it holds only what was
+ // recorded there; the notes page says how much of the log that leaves out
+ site := buildModel(title, entries, change)
+ site.Change = change
+ site.Theme, site.Light, site.Repo = theme, light, repoAbs
+ site.All = site.filesAt(strings.Split(strings.TrimRight(string(list), "\n"), "\n"), change)
commit := strings.TrimSpace(string(mustJJ(repoAbs, "log", "-r", site.Change, "--no-graph", "-T", "commit_id")))
tmp, err := os.MkdirTemp("", "vrsite-")
@@ -140,8 +152,22 @@ func writeSite(site *Site, out, srcDir string) {
}
facets := site.Facets()
+ var info *Row
+ if rows, err := LogRows(site.Repo, site.Change, "", 1); err == nil {
+ for _, row := range rows {
+ if !row.Blank() {
+ r := row
+ info = &r
+ break
+ }
+ }
+ }
render := func(path string, p *page) {
- p.Site, p.Facets, p.ChangeID = site, facets, site.Change
+ p.Site, p.Facets = site, facets
+ p.ChangeID, p.Default, p.ChangeInfo = site.Change, site.Change, info
+ p.Scope, p.Here = "change", site.NotesAt[site.Change]
+ p.Elsewhere = site.NotesTotal - p.Here
+ p.Files = site.All
f := mustCreate(path)
if err := tpl.Execute(f, p); err != nil {
fatal("render %s: %v", path, err)