Sign in

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

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

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

Self-hosted forge that lives in your Git repo.

Move release channels to an authoritative channels.db

262e516e838cfc4b16b5d00fd98d5e4ef135aa85 · Keenan Nemetz · 19d ago · parent 24019cb3

Move release channels to an authoritative channels.db

Channels are consumed from the public URL and are server-side publication state,
so they no longer live on the vole branch or in the derived index.

- forge/channel: authoritative SQLite store with schema, validation, and CRUD
- config: data/channels.db, opened and closed with the instance
- CLI: release channel set|list|clear over a new vole-channel SSH verb
- server: maintain for set/clear, read for list, annotated-tag validation,
  audit channel.set/channel.clear, JSON list
- web: channel page and tree read the store; release badges query it
- remove the metadata-branch channel parser/validator, the index-derived channel
  table, and the hook path rules
- backup, instance-data, and architecture docs include channels.db

Refs: 01M7BPHANWMSW5HK2GT0PY74QZ

forge/index/channels.go −90

@@ -1,90 +0,0 @@
1 package index
2
3 // Release channels: channels/<name>.md on the metadata branch names one release.
4 // The rows are derived with the rest of the branch, so a channel page and a
5 // release page's badges are two reads of one snapshot rather than two Git walks.
6
7 import (
8 "database/sql"
9 "errors"
10 "time"
11
12 "rodent.software/vole/metadata"
13 )
14
15 func replaceChannels(tx execer, repoID string, channels []metadata.Channel) error {
16 if _, err := tx.Exec(`DELETE FROM release_channels WHERE repo_id=?`, repoID); err != nil {
17 return err
18 }
19 for _, ch := range channels {
20 if _, err := tx.Exec(
21 `INSERT OR REPLACE INTO release_channels
22 (repo_id, name, tag, tag_object, updated_by, updated_at, description)
23 VALUES (?,?,?,?,?,?,?)`,
24 repoID, ch.Name, ch.Release, ch.ReleaseObject, ch.UpdatedBy, ch.UpdatedAt.Unix(), ch.Description); err != nil {
25 return err
26 }
27 }
28 return nil
29 }
30
31 // Channels returns every channel for a repository, sorted by name.
32 func (s *Store) Channels(repoID string) ([]metadata.Channel, error) {
33 rows, err := s.db.Query(
34 `SELECT name, tag, tag_object, updated_by, updated_at, description
35 FROM release_channels WHERE repo_id=? ORDER BY name`, repoID)
36 if err != nil {
37 return nil, err
38 }
39 defer rows.Close()
40 var out []metadata.Channel
41 for rows.Next() {
42 var ch metadata.Channel
43 var at int64
44 if err := rows.Scan(&ch.Name, &ch.Release, &ch.ReleaseObject, &ch.UpdatedBy, &at, &ch.Description); err != nil {
45 return nil, err
46 }
47 ch.UpdatedAt = time.Unix(at, 0).UTC()
48 out = append(out, ch)
49 }
50 return out, rows.Err()
51 }
52
53 // Channel returns one channel by name.
54 func (s *Store) Channel(repoID, name string) (metadata.Channel, bool, error) {
55 var ch metadata.Channel
56 var at int64
57 err := s.db.QueryRow(
58 `SELECT name, tag, tag_object, updated_by, updated_at, description
59 FROM release_channels WHERE repo_id=? AND name=?`, repoID, name).
60 Scan(&ch.Name, &ch.Release, &ch.ReleaseObject, &ch.UpdatedBy, &at, &ch.Description)
61 if err != nil {
62 if errors.Is(err, sql.ErrNoRows) {
63 return metadata.Channel{}, false, nil
64 }
65 return metadata.Channel{}, false, err
66 }
67 ch.UpdatedAt = time.Unix(at, 0).UTC()
68 return ch, true, nil
69 }
70
71 // ChannelsForTag returns the channel names that currently point at a tag,
72 // sorted. The release page shows them as badges.
73 func (s *Store) ChannelsForTag(repoID, tag string) ([]string, error) {
74 rows, err := s.db.Query(
75 `SELECT name FROM release_channels WHERE repo_id=? AND tag=? ORDER BY name`,
76 repoID, tag)
77 if err != nil {
78 return nil, err
79 }
80 defer rows.Close()
81 var out []string
82 for rows.Next() {
83 var name string
84 if err := rows.Scan(&name); err != nil {
85 return nil, err
86 }
87 out = append(out, name)
88 }
89 return out, rows.Err()
90 }