Skip to content

mitjafelicijan/bbgit

Repository files navigation

bbgit

A Git web interface written in Go.

Features

  • Repository Management: Supports multiple repositories grouped by category in config.yaml.
  • Browsing: Navigate commit history, directory files, and file contents.
  • Syntax Highlighting: Automatic language detection and highlighting via Chroma.
  • Markdown Rendering: Renders README files with GFM support and GitHub-style alerts via Goldmark.
  • Language Statistics: Visual breakdown of programming languages used in each repository.
  • Marker Scanning: Scans for TODO: and FIXME: comments across repository source files.
  • Diffs & Patches: Side-by-side diff view for commits and raw patch export.
  • Archives: Download repository snapshots as .tar.gz.
  • RSS Feeds: Commit history and tag updates delivered via standard RSS feeds.
  • Caching: Persistent caching of commit statistics and repository metadata to improve performance.

Getting Started

  1. Configure: Define your repositories in config.yaml:
    repositories:
      - name: "my-project"
        path: "/path/to/repo"
        description: "Project description"
        group: "Category"
  2. Run:
    go run .
  3. Access: Open http://localhost:8080

Configuration

The config.yaml file defines the repositories served by bbgit:

Field Description
name Unique identifier used in the URL (/r/{name}).
path Absolute path to the local Git repository.
description Short text displayed on the repository index.
group Category name used to group repositories on the home page.

Deployment (systemd)

  1. Copy the service file:
    sudo cp bbgit.service /etc/systemd/system/
  2. Edit /etc/systemd/system/bbgit.service to set the correct User, Group, WorkingDirectory, and ExecStart paths.
  3. Reload and start:
    sudo systemctl daemon-reload
    sudo systemctl enable --now bbgit

Reverse Proxy (Nginx)

To serve bbgit behind Nginx, add the following to your server block:

location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Technical Details

  • Language: Go 1.22+
  • No external JS: Server-side rendered using Go templates.
  • Metadata Cache: Stored in bbgit.cache. Persistent data is saved on SIGINT or SIGTERM.
  • Build: Compile a static binary with go build -o bbgit ..

Routing Table

Endpoint Description
/ Home page with grouped repository list.
/r/{name} Commit history (log) for the repository.
/r/{name}/files/{path} Directory file browser.
/r/{name}/blob/{path} File viewer with syntax highlighting.
/r/{name}/raw/{path} Raw file download.
/r/{name}/markers Results of the TODO: and FIXME: scanner.
/r/{name}/commits.rss RSS feed for commit history (supports ?ref=).
/r/{name}/tags.rss RSS feed for repository tags.
/r/{name}/archive/{path} Snapshot download in .tar.gz format.
/r/{name}/c/{hash} Commit detail view with side-by-side diff.
/r/{name}/c/{hash}/patch Raw patch file for the commit.

Libraries

  • go-git: Git implementation in Go.
  • Chroma: General purpose syntax highlighter.
  • Goldmark: Markdown parser and renderer.
  • go-enry: Programming language detection.
  • yaml.v3: YAML support for configuration.

License

BSD 2-Clause License. See LICENSE for details.

About

Simple Git web interface in Go

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors