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.
Manage release channels from the releases page
de72893e35f2fe73bb1741b88dcbabdfb238c8b0 · Keenan Nemetz · 17d ago · parent 529a8457
Manage release channels from the releases page Channels no longer have a separate listing page. Releases shows the channel list, a badge on each target release, and a maintainer form that creates, moves, and clears channels with the same validation and audit record as the CLI.
server/web/releases.go +75−11
| @@ -46,6 +46,72 @@ const archiveConc = 4 | |||
| 46 | 46 | // thousand commits wide is a report, not a page. | |
| 47 | 47 | const maxReleaseCommits = 100 | |
| 48 | 48 | ||
| 49 | // channelForm is the browser form for creating or moving one channel. Editing | ||
| 50 | // locks the name: the CLI has no rename either, and a channel's identity is its | ||
| 51 | // URL. | ||
| 52 | type channelForm struct { | ||
| 53 | Name string | ||
| 54 | Tag string | ||
| 55 | Description string | ||
| 56 | Editing bool | ||
| 57 | Error string | ||
| 58 | } | ||
| 59 | |||
| 60 | type releasesView struct { | ||
| 61 | Page | ||
| 62 | Name string | ||
| 63 | Tags []git.Tag | ||
| 64 | Lightweight int | ||
| 65 | Channels []channelRow | ||
| 66 | ChannelsByTag map[string][]string | ||
| 67 | CanManage bool | ||
| 68 | ManageChannels bool | ||
| 69 | ChannelForm channelForm | ||
| 70 | } | ||
| 71 | |||
| 72 | func (w *Web) releasesView(r *http.Request, m *repo.Meta, tags []git.Tag) releasesView { | ||
| 73 | light := 0 | ||
| 74 | byName := make(map[string]git.Tag, len(tags)) | ||
| 75 | for _, t := range tags { | ||
| 76 | if !t.Annotated { | ||
| 77 | light++ | ||
| 78 | } | ||
| 79 | byName[t.Name] = t | ||
| 80 | } | ||
| 81 | |||
| 82 | // Channels live on this page: the card keeps their metadata, and a badge on | ||
| 83 | // the target tag row says which release each name follows. One pass over the | ||
| 84 | // list also finds a dangling target, which a per-tag lookup cannot. | ||
| 85 | list := w.channels(m) | ||
| 86 | rows := make([]channelRow, 0, len(list)) | ||
| 87 | byTag := make(map[string][]string, len(list)) | ||
| 88 | for _, ch := range list { | ||
| 89 | t, ok := byName[ch.Release] | ||
| 90 | ok = ok && channelTargetFromTag(t, ch) | ||
| 91 | rows = append(rows, channelRow{ | ||
| 92 | Channel: ch, | ||
| 93 | Target: ch.Release, | ||
| 94 | Dangling: !ok, | ||
| 95 | Body: w.renderMarkdown(m.Name, ch.Description), | ||
| 96 | }) | ||
| 97 | if ok { | ||
| 98 | byTag[ch.Release] = append(byTag[ch.Release], ch.Name) | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | canManage := w.canManageReleases(r, m) | ||
| 103 | return releasesView{ | ||
| 104 | Page: w.page(r, m.Name+" · releases"), | ||
| 105 | Name: m.Name, | ||
| 106 | Tags: tags, | ||
| 107 | Lightweight: light, | ||
| 108 | Channels: rows, | ||
| 109 | ChannelsByTag: byTag, | ||
| 110 | CanManage: canManage, | ||
| 111 | ManageChannels: canManage && w.ChannelStore != nil, | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 49 | 115 | func (w *Web) Releases(rw http.ResponseWriter, r *http.Request) { | |
| 50 | 116 | m, ok := w.open(rw, r) | |
| 51 | 117 | if !ok { | |
| @@ -56,19 +122,17 @@ func (w *Web) Releases(rw http.ResponseWriter, r *http.Request) { | |||
| 56 | 122 | w.serverError(rw, r, "cannot list tags: "+err.Error()) | |
| 57 | 123 | return | |
| 58 | 124 | } | |
| 59 | light := 0 | ||
| 60 | for _, t := range tags { | ||
| 61 | if !t.Annotated { | ||
| 62 | light++ | ||
| 125 | view := w.releasesView(r, m, tags) | ||
| 126 | if view.CanManage { | ||
| 127 | if name := strings.TrimSpace(r.URL.Query().Get("channel")); name != "" { | ||
| 128 | if ch, ok := w.channel(m, name); ok { | ||
| 129 | view.ChannelForm = channelForm{ | ||
| 130 | Name: ch.Name, Tag: ch.Release, Description: ch.Description, Editing: true, | ||
| 131 | } | ||
| 132 | } | ||
| 63 | 133 | } | |
| 64 | 134 | } | |
| 65 | w.render(rw, "releases", struct { | ||
| 66 | Page | ||
| 67 | Name string | ||
| 68 | Tags []git.Tag | ||
| 69 | Lightweight int | ||
| 70 | CanManage bool | ||
| 71 | }{w.page(r, m.Name+" · releases"), m.Name, tags, light, w.canManageReleases(r, m)}, 0) | ||
| 135 | w.render(rw, "releases", view, 0) | ||
| 72 | 136 | } | |
| 73 | 137 | ||
| 74 | 138 | func (w *Web) ReleaseView(rw http.ResponseWriter, r *http.Request) { | |