repos / pgit

static site generator for git
git clone https://github.com/picosh/pgit.git

commit
9365859
parent
173794d
author
Eric Bower
date
2023-08-15 00:24:18 +0000 UTC
chore: speed it up
1 files changed,  +20, -7
M main.go
+20, -7
 1@@ -533,6 +533,9 @@ func getRefsURL() template.URL {
 2 	return template.URL(url)
 3 }
 4 
 5+// controls the url for trees and logs
 6+// /logs/getRevIDForURL()/index.html
 7+// /tree/getRevIDForURL()/item/file.x.html
 8 func getRevIDForURL(info RevInfo) string {
 9 	return info.Name()
10 }
11@@ -667,8 +670,12 @@ func (c *Config) writeRepo() *BranchOutput {
12 			SiteURLs: c.getURLs(),
13 		}
14 
15-		branchOutput := c.writeRevision(repo, data, refInfoList)
16-		if !claimed {
17+		if claimed {
18+			go func() {
19+				c.writeRevision(repo, data, refInfoList)
20+			}()
21+		} else {
22+			branchOutput := c.writeRevision(repo, data, refInfoList)
23 			mainOutput = branchOutput
24 			claimed = true
25 		}
26@@ -742,7 +749,7 @@ func (c *Config) writeRevision(repo *git.Repository, pageData *PageData, refs []
27 		var lastCommits []*git.Commit
28 		// `git rev-list` is pretty expensive here, so we have a flag to disable
29 		if pageData.Repo.HideTreeLastCommit {
30-			c.Logger.Info("skipping finding last commit for each file")
31+			c.Logger.Info("skipping the process of finding the last commit for each file")
32 		} else {
33 			lastCommits, err = repo.RevList([]string{pageData.RevData.ID()}, git.RevListOptions{
34 				Path:           entry.Path,
35@@ -771,11 +778,17 @@ func (c *Config) writeRevision(repo *git.Repository, pageData *PageData, refs []
36 		pageData.RevData.Name(),
37 	)
38 
39-	c.writeLog(pageData, logs)
40-	c.writeLogDiffs(repo, pageData, logs)
41-	c.writeTree(pageData, treeEntries)
42-	readme := c.writeHTMLTreeFiles(pageData, treeEntries)
43+	go func() {
44+		c.writeLog(pageData, logs)
45+	}()
46+	go func() {
47+		c.writeLogDiffs(repo, pageData, logs)
48+	}()
49+	go func() {
50+		c.writeTree(pageData, treeEntries)
51+	}()
52 
53+	readme := c.writeHTMLTreeFiles(pageData, treeEntries)
54 	output.Readme = readme
55 	return output
56 }