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.
Resolve change references on the server, not only in the clone
1eac85526b68e855bbef356cfd8deffb44643481 · Keenan Nemetz · 3d ago · parent d74e7e23
Resolve change references on the server, not only in the clone is the one change verb that lands on the server, so it was also the one that passed the typed argument straight to landing.Prepare. Prepare reads a ULID, and the shared #number alias was refused with "requests: no request 2". Resolve the reference where the landing happens: the server reads the metadata branch it owns, finds the request, and passes the canonical ULID to the plan, the merge-when-ready arm and the record. The status verb takes the same path, so both server-side change verbs accept what the help promises: a ULID, a prefix, or a number with or without #. Fixes 01M7B8J64AM5BC75Y9335107ZV.
server/integration_test.go +61
| @@ -1568,6 +1568,67 @@ func TestRequestPageSaysWhenItWouldConflict(t *testing.T) { | |||
| 1568 | 1568 | } | |
| 1569 | 1569 | } | |
| 1570 | 1570 | ||
| 1571 | // TestChangeMergeTakesTheNumberAlias: every change command resolves a typed id | ||
| 1572 | // from the clone, except merge, which asks the server to land. The server has to | ||
| 1573 | // resolve the number too, or the one command that most needs the short form is the | ||
| 1574 | // one that refuses it. Both spellings are pinned here, against real landings. | ||
| 1575 | func TestChangeMergeTakesTheNumberAlias(t *testing.T) { | ||
| 1576 | t.Parallel() | ||
| 1577 | f := newFixture(t) | ||
| 1578 | f.publish(f.repo) | ||
| 1579 | base := workRepo(t, map[string]string{"readme.md": "v1\n"}) | ||
| 1580 | if _, errs, err := f.git(base, "push", f.sshURL(f.repo), "main:refs/heads/main"); err != nil { | ||
| 1581 | t.Fatalf("initial main: %s", errs) | ||
| 1582 | } | ||
| 1583 | |||
| 1584 | // The first request is merged by its bare number. | ||
| 1585 | work, head := f.cloneWithChange(t, map[string]string{"first.md": "one\n"}, "first") | ||
| 1586 | if _, errs, err := f.git(work, "push", f.sshURL(f.repo), "HEAD:refs/heads/first"); err != nil { | ||
| 1587 | t.Fatalf("first push: %s", errs) | ||
| 1588 | } | ||
| 1589 | meta := f.newMetaRepo(t) | ||
| 1590 | if err := meta.apply(map[string]string{ | ||
| 1591 | "changes/" + reqID + "/change.md": requestMeta("main", head, "wilbur"), | ||
| 1592 | }, "request 1"); err != nil { | ||
| 1593 | t.Fatalf("request 1: %v", err) | ||
| 1594 | } | ||
| 1595 | out, errs, err := f.cli(work, "change", "merge", "1") | ||
| 1596 | if err != nil { | ||
| 1597 | t.Fatalf("change merge 1: %v\n%s", err, errs) | ||
| 1598 | } | ||
| 1599 | if !strings.Contains(out, "merged "+reqID+" into main") { | ||
| 1600 | t.Fatalf("change merge 1 answered %q, want it to name the request it landed", out) | ||
| 1601 | } | ||
| 1602 | firstHead := head | ||
| 1603 | |||
| 1604 | // The second is built on the new main and merged by `#2`. | ||
| 1605 | const secondID = "01M5JR2JK29KKMAA1T9MDNTR02" | ||
| 1606 | work, head = f.cloneWithChange(t, map[string]string{"second.md": "two\n"}, "second") | ||
| 1607 | if _, errs, err := f.git(work, "push", f.sshURL(f.repo), "HEAD:refs/heads/second"); err != nil { | ||
| 1608 | t.Fatalf("second push: %s", errs) | ||
| 1609 | } | ||
| 1610 | if err := meta.apply(map[string]string{ | ||
| 1611 | "changes/" + secondID + "/change.md": requestMeta("main", head, "wilbur"), | ||
| 1612 | }, "request 2"); err != nil { | ||
| 1613 | t.Fatalf("request 2: %v", err) | ||
| 1614 | } | ||
| 1615 | out, errs, err = f.cli(work, "change", "merge", "#2") | ||
| 1616 | if err != nil { | ||
| 1617 | t.Fatalf("change merge #2: %v\n%s", err, errs) | ||
| 1618 | } | ||
| 1619 | if !strings.Contains(out, "merged "+secondID+" into main") { | ||
| 1620 | t.Fatalf("change merge #2 answered %q, want it to name the request it landed", out) | ||
| 1621 | } | ||
| 1622 | |||
| 1623 | // Both landings are in the branch, not only in the answers. | ||
| 1624 | repoDir := filepath.Join(f.cfg.ReposDir(), f.repo+".git") | ||
| 1625 | for _, landed := range []string{firstHead, head} { | ||
| 1626 | if _, _, err := runGit(t, repoDir, "merge-base", "--is-ancestor", landed, "refs/heads/main"); err != nil { | ||
| 1627 | t.Fatalf("landed head %s is not in main: %v", landed, err) | ||
| 1628 | } | ||
| 1629 | } | ||
| 1630 | } | ||
| 1631 | |||
| 1571 | 1632 | // TestRequestDiscussionIsPushedAndOwned: a change request can be discussed, and | |
| 1572 | 1633 | // the discussion is the same kind of file as an issue comment — pushed, validated | |
| 1573 | 1634 | // at the boundary, and owned by whoever wrote it. Without this, the only ways to | |