# g2h - Generate Hugo style markdown pages from your git repository history

This program allows you to generate markdown files to have a static web based interface for navigating git repositores.
Something like [cgit](https://git.zx2c4.com/cgit/) for static websites, like [stagit](https://codemadness.org/stagit.html), but emitting Markdown for use in [Hugo](https://gohugo.io)[^1].

## Goals

- Generate static pages for projects fitting for the size of a personal homepage.
- Generate markdown that can easily be integrated with Hugo.
- Make full tree state and individual files for every commit viewable and also downloadable.
- Work for [me](https://c.onl).

## Non-goals

- Provide codesearch.
- Replacement for Git forges.
- Replace cgit.
- Work for large projects, as they may be found in a company (like) setting.
- Implement any work that should be taken care of by Hugo, e.g. combining multiple projects onto a single page, feeds and custom styling.

## Usage

Let's assume your git project is in `~/development/project` and the sources for your static site are in `~/web/page`.
Then you would run this command:
```bash
g2h --repo ~/development/project --out ~/web/page --title "My awesome project" --static-subdir project --content-subdir git/project
```
The markdown files for Hugo will be placed in `~/web/page/content/git/project` and static files, like tarballs for each commit and individual file hashes, into `~/web/page/static/project`.
For a full list of options, their defaults and how they're changing the behavior of the program run `g2h --help`.

## Features

- [x] Overview page.
      Table of branches and table of tags.
      Each with name, most recent message summary and last modified date.
    - [x] Link branch and tag name to tree view.
    - [x] Link commit messages to commit page.
    - [x] Set `date` frontmatter to latest commit date from repo.
- [x] Log page.
      Table with branch/tag, message summary and last modified date columns.
    - [x] Link commit messages to commit page.
    - [ ] Tabbed log page.
- [x] Commit page.
      Collection of metadata at the beginning of the page.
      Consisting of commit hash, commit date, author
      Followed by the commit message and then a list of changed files.
    - [x] Add redacted email to author.
    - [ ] Add links to parent(s).
    - [ ] Add links to child(ren).
    - [ ] Show diffstat on commit page.
    - [x] Add button to browse tree.
    - [ ] Add button to download tree tarball.
- [x] Tree view.
      Show the state of the tree at the current commit.
    - [x] Folders should be traversable by clicking on their name.
    - [x] Clicking on a file should open that file's page.
- [x] Individual file page.
      File content in a codeblock with file extension based language detection.
      For binary files a note that it can't be displayed.
    - [x] Don't treat pictures as binary files.
    - [x] Breadcrumbs for navigating.
    - [ ] Add button to download raw file.
- [ ] Nav bar for navigating the pages mentioned above.
    - [ ] Link to special readme, if a readme can be found, rendering markdown.
- [ ] Wrapper script that takes care of `venv` setup.
- [ ] Limit to certain branch(es).
- [ ] Limit commit range.
- [ ] Parallelize generating output.

[^1]: I'm using Hugo but any static site generator with a similar layout should work.
