1
0
Fork 0
mirror of https://github.com/imjasonh/infinite-git synced 2026-07-08 00:55:26 +00:00

Implement infinite Git HTTP server

This server generates a new commit every time someone pulls from it.
Features:
- Pure Go implementation of Git object format and protocols
- No dependency on git CLI commands
- Thread-safe commit generation
- Read-only Git HTTP smart protocol support
- Comprehensive test suite

Each pull creates a new commit with a unique file containing a timestamp
and counter, making the repository grow infinitely with each pull operation.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jason Hall 2025-07-23 21:19:02 -04:00
parent fefad053a8
commit 30ca57dae3
Failed to extract signature
19 changed files with 2172 additions and 0 deletions

80
plan.md Normal file
View file

@ -0,0 +1,80 @@
# Infinite Git HTTP Server Implementation Plan
## Overview
I'll implement a Go HTTP server that generates a new commit every time a client pulls from the repository. This creates an "infinite" Git repository where the `main` branch is updated with a new commit on each fetch operation.
## Key Components
### 1. HTTP Endpoints
- `GET /info/refs?service=git-upload-pack` - Reference discovery (triggers commit generation)
- `POST /git-upload-pack` - Handle fetch/clone with dynamically generated commits
- Reject all push operations with 403 Forbidden
### 2. Core Modules
- `pktline` package - Handle Git's packet line format
- `server` package - HTTP server and routing
- `generator` package - Generate new commits on demand
- `upload` package - Modified git-upload-pack to serve dynamic content
- `repo` package - Git repository management
### 3. Commit Generation Strategy
- On each pull request, generate a new commit with:
- Timestamp in commit message
- Unique content (e.g., pull counter, random data, or timestamp)
- Parent pointing to previous HEAD of main
- Update main branch to point to new commit
- Use Git plumbing commands or go-git library for commit creation
### 4. Project Structure
```
.
├── cmd/
│ └── infinite-git/
│ └── main.go # Entry point
├── internal/
│ ├── pktline/
│ │ ├── reader.go # Pkt-line reader
│ │ └── writer.go # Pkt-line writer
│ ├── server/
│ │ ├── server.go # HTTP server
│ │ └── handlers.go # HTTP handlers
│ ├── generator/
│ │ └── commit.go # Commit generation logic
│ ├── upload/
│ │ └── pack.go # Modified git-upload-pack
│ └── repo/
│ └── repo.go # Repository management
├── go.mod
└── README.md
```
### 5. Implementation Details
- Initialize a bare Git repository on server startup
- Intercept ref discovery requests to generate new commits
- Use mutex to handle concurrent pull requests safely
- Generate commits using either:
- `git hash-object`, `git update-index`, `git write-tree`, `git commit-tree`
- Or go-git library for pure Go implementation
- Each commit could contain:
- A file with incrementing counter
- Timestamp of the pull request
- Client information (if available)
### 6. Features
- Thread-safe commit generation
- Persistent Git repository on disk
- Configurable commit content generation
- Rate limiting (optional)
- Logging of all pull operations
- Environment variable configuration
## Example Behavior
```bash
# First client pull
$ git pull origin main
# Gets commit 1a2b3c4... "Pull #1 at 2024-01-20 10:00:00"
# Second client pull (moments later)
$ git pull origin main
# Gets commit 5d6e7f8... "Pull #2 at 2024-01-20 10:00:05"
```