Commit de8062b

Eric Bower  ·  2023-08-04 15:47:29 -0400 EDT
parent a41a46b
progress
2 files changed,  +22, -23
+4, -0
......@@ -9,3 +9,7 @@ build:
99 static: build clean
1010 ./pgit
1111 .PHONY:
12+
13+deploy:
14+ scp -R ./public/* erock@pgs.sh:/git
15+.PHONY: deploy
+18, -23
......@@ -187,7 +187,7 @@ func writeRootSummary(data *PageData) {
187187 func writeSummary(data *PageData) {
188188 writeHtml(&WriteData{
189189 Name: "index.html",
190- Subdir: filepath.Join("tree", data.RevName),
190+ Subdir: filepath.Join("tree", data.RevName),
191191 Template: "./html/summary.page.tmpl",
192192 Data: data,
193193 RepoName: data.Repo.Name,
......@@ -197,7 +197,7 @@ func writeSummary(data *PageData) {
197197 func writeTree(data *PageData) {
198198 writeHtml(&WriteData{
199199 Name: "index.html",
200- Subdir: filepath.Join("tree", data.RevName),
200+ Subdir: filepath.Join("tree", data.RevName),
201201 Template: "./html/tree.page.tmpl",
202202 Data: data,
203203 RepoName: data.Repo.Name,
......@@ -207,7 +207,7 @@ func writeTree(data *PageData) {
207207 func writeLog(data *PageData) {
208208 writeHtml(&WriteData{
209209 Name: "index.html",
210- Subdir: filepath.Join("logs", data.RevName),
210+ Subdir: filepath.Join("logs", data.RevName),
211211 Template: "./html/log.page.tmpl",
212212 Data: data,
213213 RepoName: data.Repo.Name,
......@@ -247,13 +247,7 @@ func writeHTMLTreeFiles(data *PageData) {
247247 }
248248
249249 func writeLogDiffs(project string, repo *git.Repository, data *PageData, cache map[string]bool) {
250- var lastCommit *CommitData
251250 for _, commit := range data.Log {
252- if lastCommit == nil {
253- lastCommit = commit
254- continue
255- }
256-
257251 commitID := commit.ID.String()
258252
259253 if cache[commitID] {
......@@ -262,25 +256,27 @@ func writeLogDiffs(project string, repo *git.Repository, data *PageData, cache m
262256 cache[commitID] = true
263257 }
264258
265- diff, err := repo.Diff(
266- lastCommit.ID.String(),
267- 0,
268- 0,
269- 0,
270- git.DiffOptions{Base: commitID},
271- )
272- bail(err)
273-
274259 ancestors, err := commit.Ancestors()
275260 bail(err)
276261
277- parentID := ""
262+ // if no ancestors exist then we are at initial commit
263+ parent := commit
278264 if len(ancestors) > 0 {
279- parent := ancestors[0]
280- if parent != nil {
281- parentID = parent.ID.String()
265+ pt := ancestors[0]
266+ parent = &CommitData{
267+ Commit: pt,
268+ URL: CommitURL(project, pt.ID.String()),
282269 }
283270 }
271+ parentID := parent.ID.String()
272+
273+ diff, err := repo.Diff(
274+ parentID,
275+ 0,
276+ 0,
277+ 0,
278+ git.DiffOptions{Base: commitID},
279+ )
284280
285281 commitData := &CommitPageData{
286282 Commit: commit,
......@@ -299,7 +295,6 @@ func writeLogDiffs(project string, repo *git.Repository, data *PageData, cache m
299295 Subdir: "commits",
300296 Repo: data.Repo,
301297 })
302- lastCommit = commit
303298 }
304299 }
305300