Sign in

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

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

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

A free and open-source forge that lives in your Git repo.

Close linked issues when a change request lands

183d48e55e14b0355db4268275893274433ce8ee · Keenan Nemetz · 14d ago · parent 097b2110

Close linked issues when a change request lands

A change request can now name the issues it closes. Landing writes closed
onto each of them in the same commit that marks the request merged, so the
merge and the closure cannot be separated: a request cannot be merged with
its issues still open, and an issue cannot be closed by a merge that did
not happen.

The link lives in request.md as a list of full issue ids, which is what
makes it reviewable: it is part of the file a reviewer reads, not a
reference buried in prose. Ids are validated when the request is written,
including that the issue exists, so a typo fails while the author is still
looking at the command instead of at the landing they have waited for.

`vole change new --closes <id>` (repeatable, comma lists accepted) sets it,
`vole change merge` reports what it closed, and the browser form takes the
same field. The request page links each issue, and the merge answer names
the ones it closed.

An issue that is already closed, or that is no longer there, is left alone:
the promise is about what a merge does, not permission to overrule somebody
who closed it deliberately. Re-marking an already-merged request closes
nothing, so a retried landing is harmless.

Closes #01M5XG8WYZ1566KZFC73WQWGX3.

server/web/writes.go +11

@@ -266,6 +266,9 @@ func (w *Web) CreateChangeRequest(rw http.ResponseWriter, r *http.Request) {
266 266 http.Error(rw, err.Error(), http.StatusBadRequest)
267 267 return
268 268 }
269 // Issues this request promises to close. They are checked when the request is
270 // written, so a typo fails here rather than at the landing.
271 req.Closes = closesField(r.PostFormValue("closes"))
269 272 if err := metadata.CreateRequest(m.Git(), req, ctx.Name); err != nil {
270 273 w.serverError(rw, r, "cannot open the change request: "+err.Error())
271 274 return
@@ -403,3 +406,11 @@ func (w *Web) MergeRequest(rw http.ResponseWriter, r *http.Request) {
403 406 }
404 407 http.Redirect(rw, r, "/r/"+m.Name+"/requests/"+id, http.StatusSeeOther)
405 408 }
409
410 // closesField splits the closes input: spaces, commas and newlines all work, because
411 // the field is one line somebody pasted issue ids into.
412 func closesField(raw string) []string {
413 return strings.FieldsFunc(raw, func(r rune) bool {
414 return r == ',' || r == ' ' || r == '\t' || r == '\n' || r == '\r'
415 })
416 }