Commit f7cf804

HPCesia <me@hpcesia.com>
2026-07-02 04:45:30
Fix validateRepoPath to support bare git repos
1 parent 10a0c7f
docs/how-to-self-host-a-git-repository.md
@@ -54,30 +54,3 @@ caddy file-server --root /var/www/html --listen :8080
 ```sh
 git clone http://example.com:8080/repo
 ```
-
-## Post-receive hook (auto-update on push)
-
-To regenerate the site automatically on each push, create a
-[post-receive](https://git-scm.com/docs/git-receive-pack#_post_receive_hook)
-hook in your bare repository:
-
-```sh
-#!/bin/sh
-gitmal --git --output /var/www/html/repo /path/to/repo.git
-```
-
-```sh
-chmod +x hooks/post-receive
-```
-
-Now every `git push` triggers a fresh build, and clients can clone immediately via HTTP.
-
-## Private read-write access
-
-Keep the SSH protocol for private write access:
-
-```sh
-git remote add origin git@example.com:repo.git
-git push origin main
-git clone http://example.com/repo   # public, read-only
-```
main.go
@@ -3,6 +3,7 @@ package main
 import (
 	"fmt"
 	"os"
+	"os/exec"
 	"path/filepath"
 	"regexp"
 	"runtime/pprof"
@@ -399,9 +400,10 @@ func validateRepoPath(path string) error {
 	if !info.IsDir() {
 		return fmt.Errorf("repo path %q is not a directory", path)
 	}
-	gitDir := filepath.Join(path, ".git")
-	if info, err := os.Stat(gitDir); err != nil || !info.IsDir() {
-		return fmt.Errorf("repo path %q does not contain a .git directory", path)
+	cmd := exec.Command("git", "rev-parse", "--git-dir")
+	cmd.Dir = path
+	if _, err := cmd.Output(); err != nil {
+		return fmt.Errorf("repo path %q is not a git repository", path)
 	}
 	return nil
 }
README.md
@@ -2,9 +2,10 @@
 
 # Gitmal
 
-> **⚠️ This repository is a fork of [upstream](https://github.com/antonmedv/gitmal).**
->
-> **⚠️ All commits after the fork are generated by LLM Coding Agent and have not been reviewed by humans. Use at your own risk.**
+> This repository is a fork of [upstream](https://github.com/antonmedv/gitmal).
+
+> [!WARNING]
+> ** All commits after the fork are generated by LLM Coding Agent and have not been reviewed by humans. Use at your own risk.**
 
 Gitmal is a static page generator for Git repositories. Gitmal generates static HTML pages with files, commits,
 code highlighting, and markdown rendering.