pgit
A static site generator for git.
This golang binary will generate a commit log, files, and references based on a git repository and the provided revisions.
It will only generate a commit log and files for the provided revisions.
usage
building with make
make build
./pgit --revs main --label pico --out ./public
building with nix flakes
Build the project:
nix build
This creates a result symlink containing the pgit binary at result/bin/pgit.
Run the binary:
./result/bin/pgit --revs main --label pico --out ./public
development shell
Enter a development environment with all dependencies:
nix develop
Or run a single command:
nix develop --command make build
To learn more about the options run:
./pgit --help
themes
We support all chroma themes. We do our best to adapt the theme of the entire site to match the chroma syntax highlighting theme. This is a “closet approximation” as we are not testing every single theme.
./pgit --revs main --label pico --out ./public --theme onedark
The default theme is dracula. If you want to change the colors for your site,
we generate a vars.css file that you are welcome to overwrite before
deploying, it will not change the syntax highlighting colors, only the main
site colors.
with multiple repos
--root-relative sets the prefix for all links (default: /). This makes it so
you can run multiple repos and have them all live inside the same static site.
pgit \
--out ./public/pico \
--home-url "https://git.erock.io" \
--revs main \
--repo ~/pico \
--root-relative "/pico/"
pgit \
--out ./public/starfx \
--home-url "https://git.erock.io" \
--revs main \
--repo ~/starfx \
--root-relative "/starfx/"
echo '<html><body><a href="/pico">pico</a><a href="/starfx">starfx</a></body></html>' > ./public/index.html
rsync -rv ./public/ pgs.sh:/git
post-commit hook
pgit includes a post-commit hook that automatically closes git-bug issues when you reference them in commit messages.
Installation
Install the hook in your repository:
./pgit install-hook --repo=/path/to/your/repo
Usage
Once installed, the hook will automatically:
- Parse your commit messages for issue references
- Add a comment “Fixed in commit [hash]” to the referenced issue
- Close the git-bug issue
Supported keywords (case-insensitive):
- fix, fixes, fixed
- close, closes, closed
- resolve, resolves, resolved
Example commit messages:
git commit -m "fixes #872a52d - resolved the memory leak"
git commit -m "This commit closes #abc1234 and resolves #def5678"
How it works
When you commit with an issue reference:
- The hook extracts the 7-character issue ID (e.g.,
872a52d) - It runs
git-bug bug comment new [ID] -m "Fixed in commit [hash]" - It runs
git-bug bug close [ID]to close the issue
When pgit generates the static site:
- Issue comments are scanned for “Fixed in commit [hash]” patterns
- These are transformed into clickable links to the commit pages
- The full 40-character hash is linked, but displayed as a 7-character short hash
Uninstallation
Remove the hook:
./pgit uninstall-hook --repo=/path/to/your/repo
This will restore any previous post-commit hook if one existed.
Special Thanks
This project was heavily inspired by stagit and is a fork of pgit.
License
The pgit project was originally licensed under MIT.