repos / pgit

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

commit
6d8b897
parent
5b50e23
author
Eric Bower
date
2023-08-10 13:24:09 +0000 UTC
cleanup
1 files changed,  +14, -10
M main.go
+14, -10
 1@@ -73,7 +73,7 @@ type RevData struct {
 2 
 3 type TagData struct {
 4 	Name string
 5-	URL template.URL
 6+	URL  template.URL
 7 }
 8 
 9 type CommitData struct {
10@@ -82,7 +82,7 @@ type CommitData struct {
11 	WhenStr    string
12 	AuthorStr  string
13 	ShortID    string
14-	Refs []*RefInfo
15+	Refs       []*RefInfo
16 	*git.Commit
17 }
18 
19@@ -117,7 +117,7 @@ type DiffRenderFile struct {
20 }
21 
22 type RefInfo struct {
23-	ID string
24+	ID      string
25 	Refspec string
26 	URL     template.URL
27 }
28@@ -577,7 +577,7 @@ func (c *Config) writeRepo() *BranchOutput {
29 	claimed := false
30 	for _, revData := range revs {
31 		refInfoMap[revData.RevName] = &RefInfo{
32-			ID: revData.ID,
33+			ID:      revData.ID,
34 			Refspec: revData.RevName,
35 			URL:     revData.TreeURL,
36 		}
37@@ -592,7 +592,7 @@ func (c *Config) writeRepo() *BranchOutput {
38 		}
39 
40 		refInfoMap[refspec] = &RefInfo{
41-			ID: ref.ID,
42+			ID:      ref.ID,
43 			Refspec: refspec,
44 		}
45 	}
46@@ -614,13 +614,13 @@ func (c *Config) writeRepo() *BranchOutput {
47 	})
48 
49 	for _, revData := range revs {
50-	data := &PageData{
51+		data := &PageData{
52 			Repo:     c,
53 			RevData:  revData,
54 			SiteURLs: c.getURLs(),
55 		}
56 
57-		branchOutput := c.writeBranch(repo, data, refInfoList)
58+		branchOutput := c.writeRevision(repo, data, refInfoList)
59 		if !claimed {
60 			mainOutput = branchOutput
61 			claimed = true
62@@ -645,8 +645,12 @@ func (c *Config) writeRepo() *BranchOutput {
63 	return mainOutput
64 }
65 
66-func (c *Config) writeBranch(repo *git.Repository, pageData *PageData, refs []*RefInfo) *BranchOutput {
67-	fmt.Printf("compiling (%s) branch (%s)\n", c.RepoName, pageData.RevData.RevName)
68+func (c *Config) writeRevision(repo *git.Repository, pageData *PageData, refs []*RefInfo) *BranchOutput {
69+	c.Logger.Infof(
70+		"compiling (%s) revision (%s)",
71+		c.RepoName,
72+		pageData.RevData.RevName,
73+	)
74 
75 	output := &BranchOutput{}
76 	pageSize := pageData.Repo.MaxCommits
77@@ -677,7 +681,7 @@ func (c *Config) writeBranch(repo *git.Repository, pageData *PageData, refs []*R
78 			AuthorStr:  commit.Author.Name,
79 			WhenStr:    timediff.TimeDiff(commit.Author.When),
80 			Commit:     commit,
81-			Refs: tags,
82+			Refs:       tags,
83 		})
84 	}
85