Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

Phase 2, first slice: issues as files on a branch

37c01e5aa9b98bbea8567e741cd3af508ae1ba7d · Keenan Nemetz · 18d ago · parent 197ecaa2

Phase 2, first slice: issues as files on a branch

Push-based issues, per the decision to keep the web read-only. The format is the
contract; nothing here requires a Vole binary on a contributor's machine.

  issues/<ulid>/meta.json
  issues/<ulid>/description.md
  issues/<ulid>/comments/<ulid>.md      on refs/heads/issues

Design points worth recording:

- IDs are ULIDs generated by the writer, so there is no server-assigned counter,
  no contention, and no ID allocation in the write path at all.
- Issues live on a branch rather than a custom ref, so a plain `git clone` carries
  them. That is the same lesson that moved the user roster off refs/vole/users:
  `git clone` only mirrors refs/heads/*.
- File-per-comment means two people replying to the same issue never touch the
  same file, so the only merge conflict is two edits to one comment.
- Validation happens in pre-receive, so a malformed tree never reaches the web.
  Every problem is reported at once with the offending path, and a rejected push
  leaves the branch unmoved.

The index gained issue rows, refreshed when the issues ref moves rather than by a
hook, plus coverage in the full rebuild. The list page reads the index; the
detail page reads git, so bodies and comments are never stale.

Markdown is rendered with goldmark and sanitised with bluemonday. Issue bodies
arrive by push, which makes them untrusted input on a public page; a test asserts
that <script> and javascript: URLs do not survive.

Verified by hand with a user who has an editor and a key: filed an issue, added a
comment, saw both rendered, then pushed an issue with no title and got back
"issues/01M5.../meta.json: title is required" with the branch unmoved.

internal/index/index.go +39

@@ -45,6 +45,25 @@ CREATE TABLE IF NOT EXISTS repos (
45 45 acl_sha TEXT NOT NULL DEFAULT '',
46 46 acl_principals INTEGER NOT NULL DEFAULT 0,
47 47 acl_default TEXT NOT NULL DEFAULT 'none'
48 );`); err != nil {
49 db.Close()
50 return nil, err
51 }
52 // Added after the first release of the index; the table is disposable, so a
53 // failed ALTER (already present) is not an error.
54 _, _ = db.Exec(`ALTER TABLE repos ADD COLUMN issues_sha TEXT NOT NULL DEFAULT ''`)
55 if _, err := db.Exec(`
56 CREATE TABLE IF NOT EXISTS issues (
57 repo_id TEXT NOT NULL,
58 id TEXT NOT NULL,
59 title TEXT NOT NULL,
60 state TEXT NOT NULL,
61 author TEXT NOT NULL,
62 created INTEGER NOT NULL,
63 updated INTEGER NOT NULL,
64 labels TEXT NOT NULL DEFAULT '',
65 comments INTEGER NOT NULL DEFAULT 0,
66 PRIMARY KEY (repo_id, id)
48 67 );`); err != nil {
49 68 db.Close()
50 69 return nil, err
@@ -52,6 +71,19 @@ CREATE TABLE IF NOT EXISTS repos (
52 71 return s, nil
53 72 }
54 73
74 // IssueRow is the indexed view of an issue: enough to list and link, not enough
75 // to render. The detail page reads the issue from git so bodies are never stale.
76 type IssueRow struct {
77 ID string
78 Title string
79 State string
80 Author string
81 Created time.Time
82 Updated time.Time
83 Labels []string
84 Comments int
85 }
86
55 87 func (s *Store) Close() error { return s.db.Close() }
56 88
57 89 // Rebuild discards the index and reconstructs it from the repo store. This is
@@ -81,6 +113,13 @@ func (s *Store) Rebuild(st *repo.Store) (int, error) {
81 113 if err := tx.Commit(); err != nil {
82 114 return 0, err
83 115 }
116 // Issue rows are indexed per repo after the repo rows exist, because the
117 // issues table is keyed by repo id.
118 for _, m := range repos {
119 if err := s.IndexIssues(m); err != nil {
120 return 0, err
121 }
122 }
84 123 return len(repos), nil
85 124 }
86 125