Commit de8062b
Eric Bower
·
2023-08-04 15:47:29 -0400 EDT
parent a41a46b
progress
M
Makefile
+4,
-0
| ... | ... | @@ -9,3 +9,7 @@ build: | |
| 9 | 9 | static: build clean | |
| 10 | 10 | ./pgit | |
| 11 | 11 | .PHONY: | |
| 12 | + | ||
| 13 | + | deploy: | |
| 14 | + | scp -R ./public/* erock@pgs.sh:/git | |
| 15 | + | .PHONY: deploy |
M
main.go
+18,
-23
| ... | ... | @@ -187,7 +187,7 @@ func writeRootSummary(data *PageData) { | |
| 187 | 187 | func writeSummary(data *PageData) { | |
| 188 | 188 | writeHtml(&WriteData{ | |
| 189 | 189 | Name: "index.html", | |
| 190 | - | Subdir: filepath.Join("tree", data.RevName), | |
| 190 | + | Subdir: filepath.Join("tree", data.RevName), | |
| 191 | 191 | Template: "./html/summary.page.tmpl", | |
| 192 | 192 | Data: data, | |
| 193 | 193 | RepoName: data.Repo.Name, |
| ... | ... | @@ -197,7 +197,7 @@ func writeSummary(data *PageData) { | |
| 197 | 197 | func writeTree(data *PageData) { | |
| 198 | 198 | writeHtml(&WriteData{ | |
| 199 | 199 | Name: "index.html", | |
| 200 | - | Subdir: filepath.Join("tree", data.RevName), | |
| 200 | + | Subdir: filepath.Join("tree", data.RevName), | |
| 201 | 201 | Template: "./html/tree.page.tmpl", | |
| 202 | 202 | Data: data, | |
| 203 | 203 | RepoName: data.Repo.Name, |
| ... | ... | @@ -207,7 +207,7 @@ func writeTree(data *PageData) { | |
| 207 | 207 | func writeLog(data *PageData) { | |
| 208 | 208 | writeHtml(&WriteData{ | |
| 209 | 209 | Name: "index.html", | |
| 210 | - | Subdir: filepath.Join("logs", data.RevName), | |
| 210 | + | Subdir: filepath.Join("logs", data.RevName), | |
| 211 | 211 | Template: "./html/log.page.tmpl", | |
| 212 | 212 | Data: data, | |
| 213 | 213 | RepoName: data.Repo.Name, |
| ... | ... | @@ -247,13 +247,7 @@ func writeHTMLTreeFiles(data *PageData) { | |
| 247 | 247 | } | |
| 248 | 248 | ||
| 249 | 249 | func writeLogDiffs(project string, repo *git.Repository, data *PageData, cache map[string]bool) { | |
| 250 | - | var lastCommit *CommitData | |
| 251 | 250 | for _, commit := range data.Log { | |
| 252 | - | if lastCommit == nil { | |
| 253 | - | lastCommit = commit | |
| 254 | - | continue | |
| 255 | - | } | |
| 256 | - | ||
| 257 | 251 | commitID := commit.ID.String() | |
| 258 | 252 | ||
| 259 | 253 | if cache[commitID] { |
| ... | ... | @@ -262,25 +256,27 @@ func writeLogDiffs(project string, repo *git.Repository, data *PageData, cache m | |
| 262 | 256 | cache[commitID] = true | |
| 263 | 257 | } | |
| 264 | 258 | ||
| 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 | - | ||
| 274 | 259 | ancestors, err := commit.Ancestors() | |
| 275 | 260 | bail(err) | |
| 276 | 261 | ||
| 277 | - | parentID := "" | |
| 262 | + | // if no ancestors exist then we are at initial commit | |
| 263 | + | parent := commit | |
| 278 | 264 | 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()), | |
| 282 | 269 | } | |
| 283 | 270 | } | |
| 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 | + | ) | |
| 284 | 280 | ||
| 285 | 281 | commitData := &CommitPageData{ | |
| 286 | 282 | Commit: commit, |