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/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

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

Assemble an issue or change from the indexed rows

9d8dd1bc7f52d0fcdfcf286734a2c7735c1d051d · Keenan Nemetz · 9d ago · parent 6b8f84c4

Assemble an issue or change from the indexed rows

The detail pages can read the same rows the lists do, as long as the
refresh runs first (it does) and the assembled record is exactly what the
branch says. Add Store.Issue and Store.Request, which put one entity back
together from its row, its comments, and — for a change — its closes and
approvals.

Two orderings had to be stored rather than inferred:

- request_closes keeps the file's position, because the branch lists the
  issues a change closes in the order the author wrote them, not in id
  order.
- comments and approvals are read in the same id/principal order git's
  path listing gives, so a rebuilt thread matches the one read from git.

The tests compare both readers field by field (reflect.DeepEqual) on an
issue with labels, assignees, a reply and a comment, and on a change with
two closes, an anchored comment and an approval. The schema version is
bumped so existing rows are rebuilt with the new column.

forge/index/comments.go +7−1

@@ -9,6 +9,7 @@ package index
9 9 // belongs to its parent, so replacing the parent replaces its comments.
10 10
11 11 import (
12 "database/sql"
12 13 "time"
13 14
14 15 "github.com/rodent-software/vole/metadata"
@@ -87,12 +88,17 @@ type CommentRow struct {
87 88 func (s *Store) Comments(repoID, kind, parent string) ([]CommentRow, error) {
88 89 rows, err := s.db.Query(
89 90 `SELECT kind, parent, id, author, created, body, reply_to, deleted, path, side, line, blob
90 FROM comments WHERE repo_id=? AND kind=? AND parent=? ORDER BY created, id`,
91 FROM comments WHERE repo_id=? AND kind=? AND parent=? ORDER BY id`,
91 92 repoID, kind, parent)
92 93 if err != nil {
93 94 return nil, err
94 95 }
95 96 defer rows.Close()
97 return scanComments(rows)
98 }
99
100 // scanComments reads the columns Comments and CommentsForRepo both select.
101 func scanComments(rows *sql.Rows) ([]CommentRow, error) {
96 102 var out []CommentRow
97 103 for rows.Next() {
98 104 var c CommentRow