Commit fae1d37

Eric Bower  ·  2023-08-07 10:20:29 -0400 EDT
parent 134e2ae
wrap
3 files changed,  +66, -46
+3, -0
......@@ -5,11 +5,14 @@ repos:
55 - main
66 - v1.0.0
77 desc: pico services - prose.sh, lists.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
8+ hide_tree_last_commit: true
89 - path: /home/erock/dev/pico/pico-ops
910 refs:
1011 - main
1112 desc: infra for pico services
13+ hide_tree_last_commit: true
1214 - path: /home/erock/dev/app-ui
1315 refs:
1416 - main
17+ - v50
1518 desc: aptible's paas web application
+3, -0
......@@ -13,9 +13,12 @@
1313 </div>
1414
1515 <div class="flex items-center gap">
16+ {{if $.Repo.HideTreeLastCommit}}
17+ {{else}}
1618 <div class="flex-1">
1719 <a href="{{.CommitURL}}" title="{{.Summary}}">{{.When}}</a>
1820 </div>
21+ {{end}}
1922 <div class="tree-size">
2023 {{if .IsTextFile}}{{.NumLines}} L{{else}}{{.Size}}{{end}}
2124 </div>
+60, -46
......@@ -32,16 +32,17 @@ type IndexPage struct {
3232 }
3333
3434 type RepoData struct {
35- Name string
36- Desc string
37- SummaryURL string
38- TreeURL string
39- LogURL string
40- RefsURL string
41- CloneURL string
42- MaxCommits int
43- RevName string
44- Readme string
35+ Name string
36+ Desc string
37+ SummaryURL string
38+ TreeURL string
39+ LogURL string
40+ RefsURL string
41+ CloneURL string
42+ MaxCommits int
43+ RevName string
44+ Readme string
45+ HideTreeLastCommit bool
4546 }
4647
4748 type CommitData struct {
......@@ -129,11 +130,12 @@ type BranchOutput struct {
129130 }
130131
131132 type RepoConfig struct {
132- Path string `mapstructure:"path"`
133- Refs []string `mapstructure:"refs"`
134- Desc string `mapstructure:"desc"`
135- MaxCommits int `mapstructure:"max_commits"`
136- Readme string `mapstructure:"readme"`
133+ Path string `mapstructure:"path"`
134+ Refs []string `mapstructure:"refs"`
135+ Desc string `mapstructure:"desc"`
136+ MaxCommits int `mapstructure:"max_commits"`
137+ Readme string `mapstructure:"readme"`
138+ HideTreeLastCommit bool `mapstructure:"hide_tree_last_commit"`
137139 }
138140
139141 type Config struct {
......@@ -454,18 +456,6 @@ func (c *Config) writeRepo(config *RepoConfig) *BranchOutput {
454456 }
455457 _, revName := filepath.Split(rev.Refspec)
456458
457- repoData := &RepoData{
458- Name: name,
459- Desc: config.Desc,
460- MaxCommits: config.MaxCommits,
461- SummaryURL: fmt.Sprintf("/%s/index.html", name),
462- TreeURL: fmt.Sprintf("/%s/tree/%s/index.html", name, revName),
463- LogURL: fmt.Sprintf("/%s/logs/%s/index.html", name, revName),
464- RefsURL: fmt.Sprintf("/%s/refs.html", name),
465- CloneURL: fmt.Sprintf("https://%s/%s.git", c.URL, name),
466- RevName: revName,
467- }
468-
469459 refInfoMap := map[string]*RefInfo{}
470460 var mainOutput *BranchOutput
471461 claimed := false
......@@ -481,15 +471,17 @@ func (c *Config) writeRepo(config *RepoConfig) *BranchOutput {
481471 }
482472
483473 branchRepo := &RepoData{
484- Name: name,
485- Desc: config.Desc,
486- MaxCommits: config.MaxCommits,
487- SummaryURL: fmt.Sprintf("/%s/index.html", name),
488- TreeURL: fmt.Sprintf("/%s/tree/%s/index.html", name, revn),
489- LogURL: fmt.Sprintf("/%s/logs/%s/index.html", name, revn),
490- RefsURL: fmt.Sprintf("/%s/refs.html", name),
491- CloneURL: fmt.Sprintf("https://%s/%s.git", c.URL, name),
492- RevName: revn,
474+ Name: name,
475+ Desc: config.Desc,
476+ MaxCommits: config.MaxCommits,
477+ Readme: config.Readme,
478+ HideTreeLastCommit: config.HideTreeLastCommit,
479+ SummaryURL: fmt.Sprintf("/%s/index.html", name),
480+ TreeURL: fmt.Sprintf("/%s/tree/%s/index.html", name, revn),
481+ LogURL: fmt.Sprintf("/%s/logs/%s/index.html", name, revn),
482+ RefsURL: fmt.Sprintf("/%s/refs.html", name),
483+ CloneURL: fmt.Sprintf("https://%s/%s.git", c.URL, name),
484+ RevName: revn,
493485 }
494486
495487 data := &PageData{
......@@ -531,6 +523,17 @@ func (c *Config) writeRepo(config *RepoConfig) *BranchOutput {
531523 return urlI > urlJ
532524 })
533525
526+ repoData := &RepoData{
527+ Name: name,
528+ Desc: config.Desc,
529+ SummaryURL: fmt.Sprintf("/%s/index.html", name),
530+ TreeURL: fmt.Sprintf("/%s/tree/%s/index.html", name, revName),
531+ LogURL: fmt.Sprintf("/%s/logs/%s/index.html", name, revName),
532+ RefsURL: fmt.Sprintf("/%s/refs.html", name),
533+ CloneURL: fmt.Sprintf("https://%s/%s.git", c.URL, name),
534+ RevName: revName,
535+ }
536+
534537 data := &PageData{
535538 Rev: rev,
536539 RevName: revName,
......@@ -544,6 +547,8 @@ func (c *Config) writeRepo(config *RepoConfig) *BranchOutput {
544547 }
545548
546549 func (c *Config) writeBranch(repo *git.Repository, pageData *PageData) *BranchOutput {
550+ fmt.Printf("compiling (%s) branch (%s)\n", pageData.Repo.Name, pageData.Repo.RevName)
551+
547552 output := &BranchOutput{}
548553 pageSize := pageData.Repo.MaxCommits
549554 if pageSize == 0 {
......@@ -576,18 +581,25 @@ func (c *Config) writeBranch(repo *git.Repository, pageData *PageData) *BranchOu
576581 for _, entry := range treeEntries {
577582 entry.Path = strings.TrimPrefix(entry.Path, "/")
578583
579- lastCommits, err := repo.RevList([]string{pageData.Rev.Refspec}, git.RevListOptions{
580- Path: entry.Path,
581- })
582- bail(err)
584+ var lastCommits []*git.Commit
585+ // `git rev-list` is pretty expensive here, so we have a flag to disable
586+ if pageData.Repo.HideTreeLastCommit {
587+ fmt.Println("skipping finding last commit for each file")
588+ } else {
589+ lastCommits, err = repo.RevList([]string{pageData.Rev.Refspec}, git.RevListOptions{
590+ Path: entry.Path,
591+ CommandOptions: git.CommandOptions{Args: []string{"-1"}},
592+ })
593+ bail(err)
583594
584- var lc *git.Commit
585- if len(lastCommits) > 0 {
586- lc = lastCommits[0]
595+ var lc *git.Commit
596+ if len(lastCommits) > 0 {
597+ lc = lastCommits[0]
598+ }
599+ entry.CommitURL = commitURL(pageData.Repo.Name, lc.ID.String())
600+ entry.Summary = lc.Summary()
601+ entry.When = timediff.TimeDiff(lc.Author.When)
587602 }
588- entry.CommitURL = commitURL(pageData.Repo.Name, lc.ID.String())
589- entry.Summary = lc.Summary()
590- entry.When = timediff.TimeDiff(lc.Author.When)
591603 entry.URL = filepath.Join(
592604 "/",
593605 pageData.Repo.Name,
......@@ -601,6 +613,8 @@ func (c *Config) writeBranch(repo *git.Repository, pageData *PageData) *BranchOu
601613 pageData.Log = logs
602614 pageData.Tree = treeEntries
603615
616+ fmt.Printf("compilation complete (%s) branch (%s)", pageData.Repo.Name, pageData.Repo.RevName)
617+
604618 writeLog(pageData)
605619 readme := writeHTMLTreeFiles(pageData)
606620 c.writeLogDiffs(repo, pageData)