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 channel forms off the releases page

ea6ce9fe5d829a7f4153793f0a096d00331f7e29 · Keenan Nemetz · 17d ago · parent de72893e

Move channel forms off the releases page

Create and edit channels on focused release subpages, leaving the
releases page with the read-only channel list and its row actions.

The new-release target is now a grouped branch and tag picker instead of
a free-text field, matching the channel form's selection of annotated
releases.

server/web/release_actions.go +45−2

@@ -8,14 +8,23 @@ package web
8 8
9 9 import (
10 10 "net/http"
11 "sort"
11 12 "strings"
12 13
14 "rodent.software/vole/core/git"
13 15 "rodent.software/vole/forge/repo"
14 16 "rodent.software/vole/metadata"
15 17 )
16 18
17 19 const maxReleaseNoteBytes = 64 << 10
18 20
21 // releaseTargets is the new-release picker: the refs a tag can be created on,
22 // grouped so a branch and a tag with the same name are not the same choice.
23 type releaseTargets struct {
24 Branches []string
25 Tags []string
26 }
27
19 28 type releaseFormView struct {
20 29 Page
21 30 Name string
@@ -24,10 +33,44 @@ type releaseFormView struct {
24 33 Notes string
25 34 Editing bool
26 35 Locked bool
27 Refs []string
36 Targets releaseTargets
28 37 Error string
29 38 }
30 39
40 // releaseTargetsFor lists the refs a new release can name. A commit id is still
41 // a valid target for the CLI, but the browser form offers the names a person can
42 // recognise; the server resolves whatever the form posts.
43 func releaseTargetsFor(g *git.Repo) releaseTargets {
44 internal := strings.TrimPrefix(metadata.Ref, "refs/heads/")
45 entries, err := g.Refs("refs/heads/", "refs/tags/")
46 if err != nil {
47 return releaseTargets{}
48 }
49 seen := make(map[string]bool, len(entries))
50 var out releaseTargets
51 for _, e := range entries {
52 switch {
53 case strings.HasPrefix(e.Name, "refs/heads/"):
54 name := strings.TrimPrefix(e.Name, "refs/heads/")
55 if name == "" || name == internal || seen["branch:"+name] {
56 continue
57 }
58 seen["branch:"+name] = true
59 out.Branches = append(out.Branches, name)
60 case strings.HasPrefix(e.Name, "refs/tags/"):
61 name := strings.TrimPrefix(e.Name, "refs/tags/")
62 if name == "" || seen["tag:"+name] {
63 continue
64 }
65 seen["tag:"+name] = true
66 out.Tags = append(out.Tags, name)
67 }
68 }
69 sort.Strings(out.Branches)
70 sort.Strings(out.Tags)
71 return out
72 }
73
31 74 // refreshReleaseEvents brings the feed's release rows up to date after the
32 75 // browser writes a tag directly on the server. A failure is logged, never
33 76 // reported over the release that already exists.
@@ -54,7 +97,7 @@ func (w *Web) releaseFormView(r *http.Request, m *repo.Meta, editing bool, tag,
54 97 return releaseFormView{
55 98 Page: w.page(r, m.Name+" · release"), Name: m.Name,
56 99 Tag: tag, Target: target, Notes: notes, Editing: editing,
57 Refs: compareRefs(m.Git()), Error: msg,
100 Targets: releaseTargetsFor(m.Git()), Error: msg,
58 101 }
59 102 }
60 103