Help us shape the future of Go! Take the 2026 Go Developer Survey

git-rest

command module
v0.34.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: BSD-2-Clause Imports: 24 Imported by: 0

README

git-rest

Go Reference CI Go Report Card Ask DeepWiki

Lightweight REST API server for reading and writing files in a git repository. A write is written and staged; a background flusher commits and pushes a burst of writes as one commit, and a periodic pull keeps the local clone in sync.

Where this fits in the bigger picture

This service is the vault writer in the bborbe task / agent pipeline. agent's task/controller calls git-rest over HTTP to create / update / delete the markdown task files that materialize Kafka task.CreateCommand events into an Obsidian vault git remote.

git-rest itself knows nothing about tasks, vaults, or Kafka — it's a generic HTTP-over-git CRUD service. Any consumer wanting an HTTP write-path into a git repo can use it.

Full system map: recurring-task-creator/docs/system-map.md.

Use Cases

  • Expose a git repo to non-git clients (HTTP-only consumers, agents, K8s pods)
  • Serve a vault/wiki/notes repo over HTTP without a database or web app
  • Multi-instance deploys: one git-rest per repo, sharing nothing but the remote

Features

  • File CRUD over HTTP — GET, POST, DELETE on /api/v1/files/{path}
  • Claim refs under refs/claims/ over HTTP — GET /api/v1/refs, PUT and DELETE on /api/v1/refs/claims/{key} with an origin-enforced compare-and-swap lease (a lost race is 409 and must not be retried)
  • Glob-based file listing
  • Auto-clone on startup if --git-remote-url is set and --repo is empty
  • Auto-init local-only repos when no remote URL is configured
  • Periodic git pull to stay in sync with the remote
  • Coalesced writes — git add + commit + push runs in a background flusher once per window (default 30s quiet, 120s ceiling), not inside the request; deletes stay synchronous
  • Optional SSH key + git author config
  • Health and readiness endpoints (readiness reflects whether the served repository path is readable)
  • Prometheus metrics on /metrics

Quick Start

# local repo, no remote (file CRUD only)
git-rest --repo /tmp/my-repo --listen :8080

# remote repo, auto-clone over SSH
git-rest \
  --repo /data \
  --listen :8080 \
  --git-remote-url git@github.com:owner/repo.git \
  --git-ssh-key /ssh/id_ed25519 \
  --git-user-name git-rest \
  --git-user-email git-rest@example.com \
  --pull-interval 30s

Configuration

All flags can be set as environment variables.

Flag Env Var Required Default Description
--listen LISTEN yes :9090 HTTP listen address
--repo REPO yes — Path to git repository on disk
--pull-interval PULL_INTERVAL no 30s Periodic git pull interval
--write-coalesce WRITE_COALESCE no true Coalesce file writes into one commit and one push per window
--write-coalesce-delay WRITE_COALESCE_DELAY no 30s Flush after the pending set has been quiet this long
--write-coalesce-max-delay WRITE_COALESCE_MAX_DELAY no 120s Flush when the oldest pending write is this old
--git-remote-url GIT_REMOTE_URL no — Remote URL to clone on startup (omit for local-only)
--git-ssh-key GIT_SSH_KEY no — Path to SSH private key for git operations
--git-user-name GIT_USER_NAME no — Git author name for commits
--git-user-email GIT_USER_EMAIL no — Git author email for commits
--sentry-dsn SENTRY_DSN no — Sentry DSN for error reporting
--sentry-proxy SENTRY_PROXY no — HTTP proxy for Sentry

Build metadata (set via build flags):

Flag Env Var Default
--build-git-version BUILD_GIT_VERSION dev
--build-git-commit BUILD_GIT_COMMIT none
--build-date BUILD_DATE —

Bootstrap Modes

git-rest decides what to do at startup based on --git-remote-url and the state of --repo:

Remote URL --repo/.git exists Action
set no git clone into --repo
set yes use existing repo, periodic pull
empty no git init empty repo, no push/pull
empty yes use existing repo, no push/pull

Local-only mode (no remote) skips all push/pull operations — useful for testing or single-node deployments.

Documentation

License

BSD-2-Clause

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
pkg
git

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL