shroomgit

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

commit 706be41259962005569e00faca5c31cf5855b130
Author: David Voznyarskiy <davidv@no-reply@disroot.org>
Date:   Mon Apr 13 23:19:38 2026 -0700

    trying to remove more instances of exec.Command that runs git commands. That command is likely the bottleneck for performance in shgit.
    
    Signed-off-by: David Voznyarskiy <davidv@no-reply@disroot.org>

diff --git a/shgit/logs.go b/shgit/logs.go
index 157b5c4..2d0f06f 100644
--- a/shgit/logs.go
+++ b/shgit/logs.go
@@ -10,7 +10,7 @@ import ( ) // overall awful
-func logTest(repo string, path string) {
+func logTest(repo string, path string, numofCommits int) {
topPart := genTopPart(repo, 1) logsDir := filepath.Join(path, "logs") @@ -19,53 +19,31 @@ func logTest(repo string, path string) { panic(err) }
- cmd, err := exec.Command(
- "git",
- "-C", repo,
- "rev-list",
- "--reverse",
- "--date-order",
- "HEAD",
- ).Output()
- if err != nil {
- panic(err)
- }
-
- hashes := strings.SplitSeq(strings.TrimSpace(string(cmd)), "\n")
-
// TODO fix formatting // TODO add coloring and links
- for hash := range hashes {
+ for i := range numofCommits {
cmd, err := exec.Command( "git",
- "-C",
- repo,
- "show",
- hash,
+ "-C", repo,
+ "show", "-1",
+ fmt.Sprintf("--skip=%d", i),
).Output() if err != nil { panic(err) } lines := strings.Split(string(cmd), "\n")
- var firstLine string
- var hash string
- if lines[0] != "" {
- firstLine = lines[0]
- } else {
- continue
- }
- fields := strings.Fields(firstLine)
- hash = fields[1]
+ commitHash := strings.Fields(lines[0])[1]
- outputFile := filepath.Join(logsDir, fmt.Sprintf("%s.html", hash))
+ outputFile := filepath.Join(logsDir, fmt.Sprintf("%s.html", commitHash))
file, _ := os.Create(outputFile) defer file.Close() file.WriteString(topPart) commitPageWriter(file, lines)
+
} } diff --git a/shgit/shgit.go b/shgit/shgit.go index 3b48283..15ec1b9 100644
--- a/shgit/shgit.go
+++ b/shgit/shgit.go
@@ -47,7 +47,7 @@ func main() { // logs.go logPage(topPart, repo, output, numofCommits)
- logTest(repo, output)
+ logTest(repo, output, numofCommits)
// tree.go treeRepo(topPart, repo, output)