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
server/hook/channels.go −90
| @@ -1,90 +0,0 @@ | |||
| 1 | package hook | ||
| 2 | |||
| 3 | // Channel moves are privileged: a channel is what a client follows, so pointing | ||
| 4 | // it at a different release changes every download under that name. The pointer | ||
| 5 | // itself is a metadata file, which contributors may write for issues; this is the | ||
| 6 | // path-level rule that keeps a contributor from moving stable. | ||
| 7 | |||
| 8 | import ( | ||
| 9 | "fmt" | ||
| 10 | "sort" | ||
| 11 | "strings" | ||
| 12 | |||
| 13 | "rodent.software/vole/core/git" | ||
| 14 | "rodent.software/vole/forge/access" | ||
| 15 | "rodent.software/vole/internal/audit" | ||
| 16 | "rodent.software/vole/metadata" | ||
| 17 | ) | ||
| 18 | |||
| 19 | // changedChannels lists the channel files a metadata push adds, changes, or | ||
| 20 | // deletes. A new metadata branch is all additions, so it is read from the tree | ||
| 21 | // rather than diffed against the empty tree. | ||
| 22 | func changedChannels(g *git.Repo, c change) (map[string]string, error) { | ||
| 23 | if c.ref != metadata.Ref || c.new == "" || c.new == git.ZeroSHA { | ||
| 24 | return nil, nil | ||
| 25 | } | ||
| 26 | if c.old == "" || c.old == git.ZeroSHA { | ||
| 27 | entries, err := g.LsTreeR(c.new) | ||
| 28 | if err != nil { | ||
| 29 | return nil, err | ||
| 30 | } | ||
| 31 | out := map[string]string{} | ||
| 32 | for _, e := range entries { | ||
| 33 | if strings.HasPrefix(e.Name, metadata.ChannelsDir+"/") { | ||
| 34 | out[e.Name] = "A" | ||
| 35 | } | ||
| 36 | } | ||
| 37 | return out, nil | ||
| 38 | } | ||
| 39 | return g.DiffStatusPaths(c.old, c.new, metadata.ChannelsDir) | ||
| 40 | } | ||
| 41 | |||
| 42 | // channelFindings enforces the role and records the move. A malformed channel | ||
| 43 | // file is left to the metadata validator; this only needs enough of it to make | ||
| 44 | // the audit entry useful. | ||
| 45 | func channelFindings(g *git.Repo, c change, role access.Role, actor, repo, auditPath string) []string { | ||
| 46 | changes, err := changedChannels(g, c) | ||
| 47 | if err != nil { | ||
| 48 | return []string{fmt.Sprintf("%s: cannot check channel changes: %v", c.ref, err)} | ||
| 49 | } | ||
| 50 | if len(changes) == 0 { | ||
| 51 | return nil | ||
| 52 | } | ||
| 53 | if !role.AtLeast(access.Maintain) { | ||
| 54 | return []string{fmt.Sprintf( | ||
| 55 | "%s: moving a release channel requires maintain access (role: %s)", c.ref, role)} | ||
| 56 | } | ||
| 57 | paths := make([]string, 0, len(changes)) | ||
| 58 | for path := range changes { | ||
| 59 | paths = append(paths, path) | ||
| 60 | } | ||
| 61 | sort.Strings(paths) | ||
| 62 | var problems []string | ||
| 63 | for _, path := range paths { | ||
| 64 | name, validName := metadata.ChannelNameFromPath(path) | ||
| 65 | action := "channel.set" | ||
| 66 | detail := path | ||
| 67 | if changes[path] == "D" { | ||
| 68 | action = "channel.clear" | ||
| 69 | if validName { | ||
| 70 | detail = name | ||
| 71 | } | ||
| 72 | } else if validName { | ||
| 73 | if raw, err := g.BlobAt(c.new, path); err == nil { | ||
| 74 | if ch, err := metadata.ParseChannel(name, raw); err == nil { | ||
| 75 | detail = name + " -> " + ch.Release | ||
| 76 | } | ||
| 77 | } | ||
| 78 | } | ||
| 79 | if err := auditLine(auditPath, audit.Record{ | ||
| 80 | Action: action, | ||
| 81 | Actor: actor, | ||
| 82 | Subject: repo, | ||
| 83 | Detail: detail, | ||
| 84 | }); err != nil { | ||
| 85 | problems = append(problems, fmt.Sprintf( | ||
| 86 | "%s: cannot record the channel change, refusing it: %v", c.ref, err)) | ||
| 87 | } | ||
| 88 | } | ||
| 89 | return problems | ||
| 90 | } | ||