shroomgit

generate static pages of git repos
git clone https://git.davidvoz.net/shroomgit.git
index
logs
tree

commit bf7aeea0a9ba06027963dcffdbc7c15c272a482d
Author: David Voznyarskiy <davidv@no-reply@disroot.org>
Date:   Wed Mar 25 17:25:23 2026 -0700

    shgit index page gen dev finished until a commit page gen is created
    
    Signed-off-by: David Voznyarskiy <davidv@no-reply@disroot.org>

diff --git a/Makefile b/Makefile
index 89f2573..f81cb3c 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,3 @@ shgit: clean: rm -rf bin
-
-test:
- @go build -o bin/shgit ./shgit
- @./bin/shgit bin/ffr bin/shgit_ffr
diff --git a/shgit/shgit.go b/shgit/shgit.go index 33e022e..21ae823 100644
--- a/shgit/shgit.go
+++ b/shgit/shgit.go
@@ -37,7 +37,7 @@ func indexPage(topPart string, repo string, output string) { defer file.Close() file.WriteString(topPart)
- file.WriteString("<h3 style=\"margin-bottom:0px\">Commits</h3>")
+ file.WriteString("<h3 style=\"margin-bottom:0px\">Recent Commits</h3>")
cmd, _ := exec.Command( "git", @@ -51,7 +51,7 @@ func indexPage(topPart string, repo string, output string) { numofCommitsStr := strings.TrimSpace(string(cmd)) numofCommits, _ := strconv.Atoi(numofCommitsStr)
- indexPageCommitTable(numofCommits, file, output)
+ indexPageCommitTable(numofCommits, file, repo, output)
file.WriteString("<h3 style=\"margin-bottom:0px\">Read Me</h3>") possibleFilePaths := []string{"README", "README.md", "readme.md"} @@ -66,11 +66,62 @@ func indexPage(topPart string, repo string, output string) { file.WriteString("\n</body>") }
-func indexPageCommitTable(numofCommits int, file *os.File, path string) {
+func indexPageCommitTable(numofCommits int, file *os.File, repo string, path string) {
notFile, _ := os.Open(path) defer notFile.Close() file.WriteString("<table>")
- file.WriteString(strconv.Itoa(numofCommits))
+ for i := range numofCommits {
+ file.WriteString("<tr>")
+
+ file.WriteString("<td>")
+ cmd, _ := exec.Command(
+ "git",
+ "-C", repo,
+ "log", "-1",
+ fmt.Sprintf("--skip=%d", i),
+ "--pretty=format:%cd",
+ "--date=format:%Y-%m-%d",
+ ).Output()
+ commit := strings.TrimSpace(string(cmd))
+ file.WriteString(commit)
+ file.WriteString("</td>")
+
+ file.WriteString("<td>")
+ cmd, _ = exec.Command(
+ "git",
+ "-C", repo,
+ "log", "-1",
+ fmt.Sprintf("--skip=%d", i),
+ "--pretty=format:%s",
+ ).Output()
+ commit = strings.TrimSpace(string(cmd))
+ maxLen := 45
+ if len(commit) > maxLen {
+ commit = commit[:maxLen] + "..."
+ }
+ // TODO add the paths to their commit pages
+ file.WriteString("<a>" + commit + "</a>")
+ file.WriteString("</td>")
+
+ file.WriteString("<td>")
+ cmd, _ = exec.Command(
+ "git",
+ "-C", repo,
+ "log", "-1",
+ fmt.Sprintf("--skip=%d", i),
+ "--pretty=format:%an",
+ ).Output()
+ commit = strings.TrimSpace(string(cmd))
+ file.WriteString(commit)
+ file.WriteString("</td>")
+
+ file.WriteString("</tr>")
+
+ if i == 4 {
+ break
+ }
+ }
+
file.WriteString("</table>") }