# Pygitweb

Gitweb reimplementation using **Python**, **FastAPI**, and **Pygit2**, ported from `git/gitweb/gitweb.perl`.

## Setup

```bash
cd pygitweb
python3 -m venv .venv
source .venv/bin/activate   # or .venv\Scripts\activate on Windows
pip install -r requirements.txt
```

## Run

```bash
cd pygitweb
.venv/bin/uvicorn pygitweb.main:app --reload --host 0.0.0.0 --port 8000
```

Or:

```bash
cd pygitweb && .venv/bin/python -m pygitweb.main
```

## Config

Set environment variables (or use a Python config file via `GITWEB_CONFIG`):

- `GITWEB_PROJECTROOT` — absolute path to directory containing git repositories (default: `/pub/scm`)
- `GITWEB_LIST` — same path or path to a project-list file
- `GITWEB_EXPORT_OK` — filename that must exist to allow export (e.g. `git-daemon-export-ok`); empty = no check
- `GITWEB_SITENAME` — site name in titles

## Routes

See [ROUTES.md](ROUTES.md) for more detail.

**No-project routes**

- `GET /` — project list
- `GET /index` — plain text project index (path, owner)
- `GET /opml` — OPML feed list

**Project-scoped actions (implemented)**

- `GET /{project}` or `a=summary` — project summary (description, owner, HEAD, tree link)
- `GET /{project}?a=tree&h=...&f=...` — directory listing (tree)
- `GET /{project}?a=blob&h=...&f=...` — file view (HTML)
- `GET /{project}?a=blob_plain&h=...&f=...` — raw file download
- `GET /{project}?a=log&h=...` — commit log
- `GET /{project}?a=shortlog&h=...` — shortlog
- `GET /{project}?a=history&h=...&f=...` — history of a file or path
- `GET /{project}?a=tags` — list all tags
- `GET /{project}?a=tag&h=...` — single tag view (tag ref or hash)
- `GET /{project}?a=commit` — commit information
- `GET /{project}?a=commitdiff` — commit diff (unified diff rendered with [diff2html](https://github.com/rtfpessoa/diff2html))
- `GET /{project}?a=commitdiff_plain` — unified diff for commit (raw text)
- `GET /{project}?a=remotes` — list repo remotes

**Project-scoped actions (stub only)**

These actions are accepted but return a minimal placeholder page. Add handlers in `main.py` to implement: `blame`, `blame_incremental`, `blame_data`, `blobdiff`, `blobdiff_plain`, `heads`, `patch`, `patches`, `rss`, `atom`, `search`, `search_help`, `snapshot`, `object`.