[PATCH RFC 0/3] ui-bugs: browse git-bug data from cgit

Konstantin Ryabitsev konstantin at linuxfoundation.org
Tue Aug 25 18:59:45 UTC 2026


git-bug (https://github.com/git-bug/git-bug) keeps issues inside the
repository itself, as ordinary git objects under refs/bugs/.  That makes
it attractive for projects hosted on plain git infrastructure, which has
no issue tracker to offer: the bugs travel with the clone, and no service
has to be run alongside the repository.  What has been missing is a way
to read them without cloning and installing the git-bug binary.

This series adds a read-only "bugs" page to cgit.  It renders nothing
itself; it invokes a filter and wraps the output.  The filter is handed
the path component -- empty for the bug list, or a bug id for a single
bug -- and produces the HTML.

Delegating rather than parsing is deliberate.  git-bug's on-disk format
is its own business and has changed before; a C implementation in cgit
would pin cgit to whatever the format looked like on the day it was
written, and every subsequent change would become a cgit bug.  A filter
also means a site can render bugs to its own taste, or point the page at
something else entirely, without patching cgit.  The cost is that the
page does nothing useful until a filter is configured, which is why
patch 2 supplies a working one.

The three patches are:

  1/3  the page handler, the config options, and the nav tab
  2/3  filters/bugs-git-bug.lua, a working filter built on ezgb.lua
       and luagit2
  3/3  tests for the C plumbing

ezgb.lua is not in this tree.  It lives under lua/ in

  https://git.kernel.org/pub/scm/utils/ezgb/ezgb.git

alongside a rockspec, so `luarocks make lua-ezgb-scm-1.rockspec' from
that checkout installs it.  It is read-only and pulls in luagit2,
luaossl and lua-cjson.

Configuration is two lines:

  enable-bugs=1
  bugs-filter=lua:/usr/share/cgit/filters/bugs-git-bug.lua

The result can be seen running at

  https://git.kernel.org/pub/scm/utils/b4/b4.git/bugs/

which is b4's own bug tracker, rendered by patch 2's filter on a cgit
carrying this series.

The page is off by default, and returns 403 rather than 404 when it is
not enabled, so a repository that already carries refs/bugs/ does not
quietly grow a new page across an upgrade.  Rendering is cached under
its own cache-bugs-ttl, defaulting to the same 15 minutes as the about
page, since invoking a filter that reads git objects is not something to
repeat per request.

A few choices worth arguing about:

- The nav tab is gated on enable-bugs alone, not on the repository
  actually having refs/bugs/.  Probing for the ref would hide the tab on
  repositories with no bugs, but it costs a ref lookup on every page of
  every repository, and it makes the tab flicker into existence when the
  first bug is filed.  I opted for the explicit switch.

- The page is registered with want_vpath=0.  A bug id is meaningful only
  to this page, and treating it as the virtual path would append it to
  the log, tree and diff tab links, sending anyone who clicked them to a
  path that does not exist.  There is a test for this.

- The example filter needs ezgb.lua, luagit2, lua-cjson (or lua-json)
  and luaossl.  That is a lot to ask of a packager, which is why it sits
  in filters/ as an example alongside the others rather than being wired
  up by the Makefile.  Nothing in cgit depends on it.

- The bug page styles go into cgit.css rather than being emitted inline
  by the filter.  A filter is free to inline its own, but a deployment
  serving a strict Content-Security-Policy would then need
  style-src 'unsafe-inline' for this one page, which seemed like the
  wrong trade to bake into the example.

Read-only is the whole scope.  Filing and commenting stay with the
git-bug CLI, which is where the Lamport clocks and the operation DAG are
kept consistent; a web form writing into that from a CGI is not a thing
I want to maintain.

This shares cgit.c, cgit.h, shared.c, cgitrc.5.txt, ui-shared.c and
ui-shared.h with the object reachability series I have out, but the two
apply cleanly in either order and neither depends on the other.

Signed-off-by: Konstantin Ryabitsev <konstantin at linuxfoundation.org>
---
Konstantin Ryabitsev (3):
      ui-bugs: add git-bug browsing via a Lua filter
      filters: add an example git-bug filter
      tests: cover the bugs page access control and config

 cgit.c                   |  18 +++
 cgit.css                 | 103 +++++++++++++
 cgit.h                   |   7 +-
 cgit.mk                  |   1 +
 cgitrc.5.txt             |  32 ++++
 cmd.c                    |  10 ++
 filter.c                 |   1 +
 filters/bugs-git-bug.lua | 384 +++++++++++++++++++++++++++++++++++++++++++++++
 shared.c                 |   2 +
 tests/t0113-bugs.sh      |  77 ++++++++++
 ui-bugs.c                |  30 ++++
 ui-bugs.h                |   6 +
 ui-shared.c              |  12 ++
 ui-shared.h              |   2 +
 14 files changed, 684 insertions(+), 1 deletion(-)
---
base-commit: 044821677c774cd24f25f1818ea51d09cc64b006
change-id: 20260825-feature-git-bug-c8042452d25e

Best regards,
--  
Konstantin Ryabitsev <konstantin at linuxfoundation.org>



More information about the CGit mailing list