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
Using make, better fns in main
author
Ben Vogt <[email protected]>
date
2023-04-03 15:11:14
stats
2 file(s) changed, 17 insertions(+), 8 deletions(-)
files
Makefile
main.go
 1diff --git a/Makefile b/Makefile
 2index 90c6595..79de3ac 100644
 3--- a/Makefile
 4+++ b/Makefile
 5@@ -19,10 +19,13 @@ cloning:
 6 clean:
 7 	rm -rf target/*
 8 
 9-dev: target output cloning
10-	OUTPUT_DIR=$(PWD)/target/output && \
11-    CLONING_DIR=$(PWD)/target/cloning && \
12-    go run main.go && \
13-    cp styles.css OUTPUT_DIR=$(PWD)/target/output/ && \
14-    cd OUTPUT_DIR=$(PWD)/target/output && \
15+target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin:
16+	go build -o target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin main.go
17+
18+dev: target output cloning target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin
19+	OUTPUT_DIR=$(PWD)/target/output \
20+    CLONING_DIR=$(PWD)/target/cloning \
21+    ./target/gshr-${OS}-${ARCH}-${ENVIRONMENT}.bin && \
22+    cp styles.css $(PWD)/target/output/ && \
23+    cd $(PWD)/target/output && \
24     python3 -m http.server 8000
25\ No newline at end of file
26diff --git a/main.go b/main.go
27index 4dbdebd..16018fb 100644
28--- a/main.go
29+++ b/main.go
30@@ -8,7 +8,7 @@ import (
31 	"path/filepath"
32 	"strings"
33 
34-	git "github.com/go-git/go-git/v5"
35+	"github.com/go-git/go-git/v5"
36 	"github.com/go-git/go-git/v5/plumbing/object"
37 )
38 
39@@ -31,6 +31,9 @@ var (
40 func main() {
41 	outputDir = os.Getenv("OUTPUT_DIR")
42 	cloningDir = os.Getenv("CLONING_DIR")
43+	line("OUTPUT_DIR = %v", outputDir)
44+	line("CLONING_DIR = %v", cloningDir)
45+	cloneAndCheck()
46 	primaryScan()
47 }
48 
49@@ -47,7 +50,7 @@ func writeFile(filename string, outputFile string, t *template.Template) {
50 	checkErr(err)
51 }
52 
53-func primaryScan() {
54+func cloneAndCheck() {
55 	r, err := git.PlainClone(cloningDir, false, &git.CloneOptions{
56 		URL: "/Users/bvogt/dev/src/ben/www",
57 	})
58@@ -65,6 +68,9 @@ func primaryScan() {
59 	})
60 	checkErr(err)
61 
62+}
63+
64+func primaryScan() {
65 	t, err := template.ParseFiles("template.html")
66 	checkErr(err)
67