gshr
git static host repo -- generates static html for repos
git clone https://git.vogt.world/gshr.git
Log | Files | README.md | LICENSE
← Commit log
commit
message
Fixing git shell working dir issue for diffing
author
Ben Vogt <[email protected]>
date
2023-04-10 19:22:26
stats
4 file(s) changed, 8 insertions(+), 7 deletions(-)
files
Makefile
commit.go
files.go
log.go
 1diff --git a/Makefile b/Makefile
 2index cc89ee5..852f4cf 100644
 3--- a/Makefile
 4+++ b/Makefile
 5@@ -7,7 +7,7 @@ target/output: target
 6 	mkdir -p target/output
 7 
 8 clean:
 9-	rm -rf target/*
10+	rm -rf target
11 
12 deps:
13 	go mod download
14diff --git a/commit.go b/commit.go
15index 3dc97e8..e819c1b 100644
16--- a/commit.go
17+++ b/commit.go
18@@ -59,10 +59,11 @@ func renderAllCommitPages(data repoData, r *git.Repository) {
19 			//       usage, but something tells me no. Fixing it by shelling out for now, since we
20 			//       require git to be installed for `git update-server-info` anyway.
21 			cmd := exec.Command("git", "diff", parent.Hash.String(), c.Hash.String())
22-			cmd.Dir = path.Join(args.OutputDir, data.Name)
23+			cmd.Dir = path.Join(args.OutputDir, data.Name, "git")
24 			var out strings.Builder
25 			cmd.Stdout = &out
26-			checkErr(cmd.Run())
27+			err = cmd.Run()
28+			checkErr(err)
29 			patchString := out.String()
30 			highlighted := highlight("x.diff", &patchString)
31 			diffContent = template.HTML(highlighted)
32diff --git a/files.go b/files.go
33index b932c49..82ffc99 100644
34--- a/files.go
35+++ b/files.go
36@@ -22,7 +22,7 @@ type FilesPage struct {
37 	Files    []FileOverview
38 }
39 
40-func (f *FilesPage) RenderPage(t *template.Template) {
41+func (f *FilesPage) renderPage(t *template.Template) {
42 	debug("file page for '%v'", f.RepoData.Name)
43 	output, err := os.Create(path.Join(args.OutputDir, f.RepoData.Name, "files.html"))
44 	checkErr(err)
45@@ -59,5 +59,5 @@ func renderAllFilesPage(data repoData) {
46 		RepoData: data,
47 		Files:    files,
48 	}
49-	index.RenderPage(t)
50+	index.renderPage(t)
51 }
52diff --git a/log.go b/log.go
53index 8f7b6fe..55bd84a 100644
54--- a/log.go
55+++ b/log.go
56@@ -26,7 +26,7 @@ type LogPage struct {
57 	Commits    []LogPageCommit
58 }
59 
60-func (l *LogPage) RenderPage(t *template.Template) {
61+func (l *LogPage) renderPage(t *template.Template) {
62 	debug("log page for '%v'", l.RepoData.Name)
63 	output, err := os.Create(path.Join(args.OutputDir, l.RepoData.Name, "log.html"))
64 	checkErr(err)
65@@ -67,5 +67,5 @@ func renderLogPage(data repoData, r *git.Repository) {
66 	(&LogPage{
67 		RepoData: data,
68 		Commits:  commits,
69-	}).RenderPage(t)
70+	}).renderPage(t)
71 }