- commit
- ec17d58
- parent
- 81f5f00
- author
- Jason Cox
- date
- 2025-03-23 23:13:06 -0400 EDT
Ensure all revisions get built (#5) The first revision builds synchronously, and then the others build in parallel. Use a wait group to ensure that the program doesn't exit before the other builds finish.
1 files changed,
+9,
-7
M
main.go
M
main.go
+9,
-7
1@@ -626,7 +626,6 @@ func (c *Config) writeRepo() *BranchOutput {
2
3 refInfoMap := map[string]*RefInfo{}
4 mainOutput := &BranchOutput{}
5- claimed := false
6 for _, revData := range revs {
7 refInfoMap[revData.Name()] = &RefInfo{
8 ID: revData.ID(),
9@@ -665,7 +664,8 @@ func (c *Config) writeRepo() *BranchOutput {
10 return urlI > urlJ
11 })
12
13- for _, revData := range revs {
14+ var wg sync.WaitGroup
15+ for i, revData := range revs {
16 c.Logger.Info("writing revision", "revision", revData.Name())
17 data := &PageData{
18 Repo: c,
19@@ -673,16 +673,18 @@ func (c *Config) writeRepo() *BranchOutput {
20 SiteURLs: c.getURLs(),
21 }
22
23- if claimed {
24+ if i == 0 {
25+ branchOutput := c.writeRevision(repo, data, refInfoList)
26+ mainOutput = branchOutput
27+ } else {
28+ wg.Add(1)
29 go func() {
30+ defer wg.Done()
31 c.writeRevision(repo, data, refInfoList)
32 }()
33- } else {
34- branchOutput := c.writeRevision(repo, data, refInfoList)
35- mainOutput = branchOutput
36- claimed = true
37 }
38 }
39+ wg.Wait()
40
41 // use the first revision in our list to generate
42 // the root summary, logs, and tree the user can click