repos / pgit

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

commit
ba01b99
parent
ed551e4
author
Neale Pickett
date
2025-12-30 14:59:34 -0500 EST
Fix nil pointer deref on unsigned commits
1 files changed,  +9, -7
M main.go
+9, -7
 1@@ -795,6 +795,9 @@ func (tw *TreeWalker) NewTreeItem(entry *git.TreeEntry, curpath string, crumbs [
 2 		Entry:  entry,
 3 		URL:    tw.Config.getFileURL(tw.PageData.RevData, fname),
 4 		Crumbs: crumbs,
 5+		Author: &git.Signature{
 6+			Name: "unknown",
 7+		},
 8 	}
 9 
10 	// `git rev-list` is pretty expensive here, so we have a flag to disable
11@@ -808,15 +811,14 @@ func (tw *TreeWalker) NewTreeItem(entry *git.TreeEntry, curpath string, crumbs [
12 		})
13 		bail(err)
14 
15-		var lc *git.Commit
16 		if len(lastCommits) > 0 {
17-			lc = lastCommits[0]
18+			lc := lastCommits[0]
19+			item.CommitURL = tw.Config.getCommitURL(lc.ID.String())
20+			item.CommitID = getShortID(lc.ID.String())
21+			item.Summary = lc.Summary()
22+			item.When = lc.Author.When.Format(time.DateOnly)
23+			item.Author = lc.Author
24 		}
25-		item.CommitURL = tw.Config.getCommitURL(lc.ID.String())
26-		item.CommitID = getShortID(lc.ID.String())
27-		item.Summary = lc.Summary()
28-		item.When = lc.Author.When.Format(time.DateOnly)
29-		item.Author = lc.Author
30 	}
31 
32 	fpath := tw.Config.getFileURL(tw.PageData.RevData, fmt.Sprintf("%s.html", fname))