1
0
Fork 0
mirror of https://github.com/imjasonh/infinite-git synced 2026-07-08 09:05:06 +00:00
infinite-git/main.go
Jason Hall 8919cd5826
Implement pure Go Git HTTP server without CLI dependencies
Major rewrite to eliminate git CLI dependency:
- Created object package for Git object format handling (blob, tree, commit)
- Implemented packfile generation from scratch
- Rewrote repo initialization to create Git repos without CLI
- Implemented git-upload-pack protocol in pure Go
- Updated all server handlers to use new implementation
- Added Git packet tracing to test.sh for debugging
- Fixed tests to work with new implementation

The server now works entirely with Go code, no git commands needed.
Clone operations work correctly, but pull operations still have protocol
negotiation issues that need further debugging.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 22:28:50 -04:00

49 lines
1.2 KiB
Go

package main
import (
"context"
"log/slog"
"net/http"
"os"
"time"
_ "github.com/chainguard-dev/clog/gcp/init"
"github.com/imjasonh/infinite-git/internal/repo"
"github.com/imjasonh/infinite-git/internal/server"
"github.com/sethvargo/go-envconfig"
)
var env = envconfig.MustProcess(context.Background(), &struct {
Port string `env:"PORT,default=8080"`
RepoPath string `env:"REPO_PATH,default=./infinite-repo"`
}{})
func main() {
// clog/gcp/init automatically sets up the logger
// Initialize repository
slog.Info("initializing repository", "env", env)
gitRepo, err := repo.New(env.RepoPath)
if err != nil {
slog.Error("failed to initialize repository", "error", err)
os.Exit(1)
}
// Create server
srv := server.New(gitRepo)
// Set up HTTP server
httpServer := &http.Server{
Addr: ":" + env.Port,
Handler: srv.Handler(),
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
IdleTimeout: 120 * time.Second,
}
slog.Info("starting HTTP server", "port", env.Port)
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
slog.Error("HTTP server error", "error", err)
os.Exit(1)
}
}