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 change update correct a request's title and description

12221a79f903723b8388c24ef6e1b850855e43b7 · Keenan Nemetz · 3d ago · parent d1c3b323

Let change update correct a request's title and description

The metadata writer already replaces a request's prose without moving the
base, head, or approvals, and it works after a request closes or merges.
Expose that through --title and -m/-F, mirroring issue edit, and document
the command. The new test holds the command to the metadata rule: an
approval stays bound to the same commit across a prose edit.

cmd/vole/change.go +28−4

@@ -41,7 +41,7 @@ var changeGroup = &group{
41 41 {Name: "comment", Synopsis: "change comment <id> [-m <text> | -F <file>] [--path <file> --line <n> [--side new|old]] [--reply-to <comment-id>]", Flags: []string{"message", "file", "path", "line", "side", "reply-to", "remote", "no-push"}},
42 42 {Name: "edit-comment", Synopsis: "change edit-comment <id> <comment-id> [-m <text> | -F <file>]", Flags: []string{"message", "file", "remote", "no-push"}},
43 43 {Name: "rm-comment", Synopsis: "change rm-comment <id> <comment-id>", Flags: []string{"remote", "no-push"}},
44 {Name: "update", Synopsis: "change update <id> [--base <branch>] [--head <rev>] [--closes <issue>]... [--no-closes]", Flags: []string{"base", "head", "closes", "no-closes", "remote", "no-push"}, Notes: []string{"`--base` retargets an open request, which is how a stacked request moves onto `main` after the branch below it lands; approvals named the old base and stop counting. `--closes` replaces the list, and `--no-closes` clears it."}},
44 {Name: "update", Synopsis: "change update <id> [--title <title>] [-m <text> | -F <file>] [--base <branch>] [--head <rev>] [--closes <issue>]... [--no-closes]", Flags: []string{"title", "message", "file", "base", "head", "closes", "no-closes", "remote", "no-push"}, Notes: []string{"`--base` retargets an open request, which is how a stacked request moves onto `main` after the branch below it lands; approvals named the old base and stop counting. `--closes` replaces the list, and `--no-closes` clears it. `--title` and `-m`/`-F` correct the prose: an approval names the base and head, so the edit leaves both and any approval alone, including on a closed or merged request."}},
45 45 {Name: "approve", Synopsis: "change approve <id> [--as <account>]", Flags: []string{"as", "remote", "no-push"}, Notes: []string{"An approval is only accepted from the account it names, and never by the author's own account."}},
46 46 {Name: "merge", Synopsis: "change merge <id>", Flags: []string{"remote"}, Notes: []string{"Lands the request. When the combined result is still building it says the request will merge when the result passes, which is the same merge-when-ready a click on the page arms."}},
47 47 {Name: "close", Synopsis: "change close <id>", Flags: []string{"remote", "no-push"}},
@@ -367,12 +367,31 @@ func cmdChange(args []string) error {
367 367
368 368 case "update":
369 369 if len(f.rest) != 1 {
370 return usagef("usage: vole change update <id> [--base <branch>] [--head <rev>] [--closes <issue>]... [--no-closes]")
370 return usagef("usage: vole change update <id> [--title <title>] [-m <text> | -F <file>] [--base <branch>] [--head <rev>] [--closes <issue>]... [--no-closes]")
371 371 }
372 372 r, err := metadata.FindRequest(c.Repo, f.rest[0])
373 373 if err != nil {
374 374 return err
375 375 }
376 // The prose is an edit, not a new proposal: only the fields that were
377 // given are touched, and an approval names the base and head, so
378 // correcting a title or description leaves them and any approval alone.
379 title, titleChanged := r.Title, false
380 if f.given("title") {
381 title = strings.TrimSpace(f.one("title"))
382 if title == "" {
383 return usagef("--title needs a value (a title cannot be emptied)")
384 }
385 titleChanged = title != r.Title
386 }
387 description, descriptionChanged := r.Description, false
388 if f.given("message") || f.given("file") {
389 if description, err = readBody(f); err != nil {
390 return err
391 }
392 descriptionChanged = description != r.Description
393 }
394 proseChanged := titleChanged || descriptionChanged
376 395 base, baseChanged := r.Base, false
377 396 if f.given("base") {
378 397 base = strings.TrimPrefix(strings.TrimSpace(f.one("base")), "refs/heads/")
@@ -411,13 +430,18 @@ func cmdChange(args []string) error {
411 430 }
412 431 linksChanged = !equalIDs(closes, r.Closes)
413 432 }
414 if !baseChanged && !headMoved && !linksChanged {
415 return usagef("nothing to update: pass --base <branch>, --head <rev> or --closes <issue>")
433 if !baseChanged && !headMoved && !linksChanged && !proseChanged {
434 return usagef("nothing to update: pass --title <title>, -m/-F, --base <branch>, --head <rev> or --closes <issue>")
416 435 }
417 436 var out *metadata.Request
418 437 reapply := func() error {
419 438 var uerr error
420 439 out = r
440 if proseChanged {
441 if out, uerr = metadata.SetRequestDetails(c.Repo, r.ID, title, description, author); uerr != nil {
442 return uerr
443 }
444 }
421 445 if baseChanged {
422 446 if out, uerr = metadata.SetRequestBase(c.Repo, r.ID, base, author); uerr != nil {
423 447 return uerr