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.

Let a release change until a channel names it

214e7ea67ccb37d356a52097f8ce838bdf4c1731 · Keenan Nemetz · 17d ago · parent 502119f4

Let a release change until a channel names it

A release is mutable again. Notes can be edited and files added, replaced,
or removed after publication, because a mistyped note or a rebuilt binary
is not a reason to cut a new version. Editing the notes re-tags the same
commit, which the old rule refused from the first attached file.

The one thing that stays frozen is a release a channel names. A channel
records the tag name and the tag object, so a re-tag would dangle it and a
changed pointer would serve different bytes under a URL a package manager
already cached. Pre-receive reads the channel table from the instance
database and refuses every change to a channeled release — tag moves and
deletes, and added, replaced, or removed pointers alike — naming the
channel and how to move it. The browser applies the same rule: the edit
form, the attach form, and the list link are all drawn from it.

Attaching also works from the browser now, at parity with the CLI. The
Artifacts card takes files, or a directory, and an optional directory to
publish under; the handler streams each part to a temp file while hashing
it, checks the object-store quota before storing anything, writes bytes
first and pointers second, and calls the same metadata writer the CLI
does. A directory upload keeps its paths, which is why the body is read as
a multipart stream rather than through ParseForm.

server/web/release_actions.go +36−10

@@ -3,16 +3,19 @@ package web
3 3 // Creating a release is creating an annotated tag, so the tag remains the whole
4 4 // release. The web form exists to make the notes, the target commit, and the
5 5 // tagger explicit; it does not introduce a second release record. Editing notes
6 // moves the tag as a new tag object, which the release rules allow only until a
7 // file has been attached.
6 // moves the tag as a new tag object, which is allowed at any time — a release is
7 // mutable — except while a channel targets it, because that channel's URL is the
8 // promise that this release stays what it is.
8 9
9 10 import (
11 "fmt"
10 12 "net/http"
11 13 "sort"
12 14 "strings"
13 15
14 16 "rodent.software/vole/core/git"
15 17 "rodent.software/vole/forge/repo"
18 "rodent.software/vole/internal/format"
16 19 "rodent.software/vole/metadata"
17 20 )
18 21
@@ -101,6 +104,32 @@ func (w *Web) releaseFormView(r *http.Request, m *repo.Meta, editing bool, tag,
101 104 }
102 105 }
103 106
107 // releaseRefusal is the one rule a release edit meets: a lightweight tag has no
108 // notes, and a channel target is frozen. Returning the reason from one place
109 // means the button a page draws and the handler that would accept the post agree.
110 func (w *Web) releaseRefusal(m *repo.Meta, t git.Tag) string {
111 if !t.Annotated {
112 return "Lightweight tags have no notes to edit."
113 }
114 names := w.channelsForTag(m, t.Name)
115 if len(names) == 0 {
116 return ""
117 }
118 return fmt.Sprintf("%s this release, so it cannot change. "+
119 "Point each channel at another release first (`vole release channel set %s <tag>`).",
120 channelNamePhrase(names), names[0])
121 }
122
123 // channelNamePhrase is the same sentence the push gate uses, so a browser and a
124 // push explain the refusal identically: "Channel stable targets" or
125 // "Channels stable and beta target".
126 func channelNamePhrase(names []string) string {
127 if len(names) == 1 {
128 return "Channel " + names[0] + " targets"
129 }
130 return "Channels " + format.Names(names) + " target"
131 }
132
104 133 func (w *Web) ReleaseNewPage(rw http.ResponseWriter, r *http.Request) {
105 134 m, ok := w.open(rw, r)
106 135 if !ok {
@@ -159,7 +188,7 @@ func (w *Web) CreateRelease(rw http.ResponseWriter, r *http.Request) {
159 188 }
160 189 if refs, err := g.ListRefs("refs/tags/"); err == nil {
161 190 if _, exists := refs["refs/tags/"+tag]; exists {
162 fail("That tag already exists. A release is immutable; choose a new tag name.")
191 fail("That tag already exists. Choose a new tag name, or edit the notes of the release it names.")
163 192 return
164 193 }
165 194 }
@@ -191,12 +220,9 @@ func (w *Web) ReleaseEditPage(rw http.ResponseWriter, r *http.Request) {
191 220 return
192 221 }
193 222 view := w.releaseFormView(r, m, true, t.Name, t.Commit, t.Message, "")
194 if !t.Annotated {
223 if msg := w.releaseRefusal(m, t); msg != "" {
195 224 view.Locked = true
196 view.Error = "Lightweight tags have no notes to edit."
197 } else if metadata.TagWithArtifacts(m.Git(), t.Name) {
198 view.Locked = true
199 view.Error = "This release has files attached, so it cannot be edited. Attach a new file or publish a new release instead."
225 view.Error = msg
200 226 }
201 227 w.render(rw, "release_form", view, 0)
202 228 }
@@ -227,8 +253,8 @@ func (w *Web) UpdateRelease(rw http.ResponseWriter, r *http.Request) {
227 253 fail("Lightweight tags have no notes to edit.")
228 254 return
229 255 }
230 if metadata.TagWithArtifacts(m.Git(), t.Name) {
231 fail("This release has files attached, so it cannot be edited.")
256 if msg := w.releaseRefusal(m, t); msg != "" {
257 fail(msg)
232 258 return
233 259 }
234 260 if strings.TrimSpace(notes) == "" {