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.
Number issues and change requests for human references
e05f1c48d4ee55635cd7b77889f0545137198106 · Keenan Nemetz · 13d ago · parent 41d1fee9
Number issues and change requests for human references A ULID is an unreadable handle, and the 8-character prefix the list showed is mostly timestamp: this repository's 27 issues shared seven distinct six-character prefixes and two pairs already collided at eight. The part people actually type carried almost no information. Issues and change requests now share one gap-free sequence (#1, #42, ...) derived from the creation order in the metadata branch's history, the way one forge counts both in a single run. The number is not stored. It is the rank of the entity's creation commit, so nothing is written when an entity is created, a repository needs no backfill, the same history gives the same numbers on every clone, and `vole admin index rebuild` reproduces them from git. A ULID stays the identity: paths, front matter, `closes:` and audit entries are unchanged, and data/index.db only caches the mapping so a page render does not walk history. Every id-taking command accepts a number, `#42` links in a body through a kind-agnostic /r/<repo>/n/42 route, and --closes resolves an alias to the ULID before writing. Closes #45
forge/index/numbers.go +45
| @@ -0,0 +1,45 @@ | |||
| 1 | package index | ||
| 2 | |||
| 3 | // The `#42` alias, as the index sees it. | ||
| 4 | // | ||
| 5 | // The number is derived from history (metadata.LoadNumbers) and cached here so a | ||
| 6 | // page render does not walk git. It is not authoritative: `vole admin index | ||
| 7 | // rebuild` recomputes every row from the metadata branch, and the answer is the | ||
| 8 | // same because the history is. | ||
| 9 | |||
| 10 | // Numbers returns every entity number in a repo, keyed by entity id. | ||
| 11 | func (s *Store) Numbers(repoID string) (map[string]int, error) { | ||
| 12 | rows, err := s.db.Query(`SELECT id, number FROM entity_numbers WHERE repo_id=?`, repoID) | ||
| 13 | if err != nil { | ||
| 14 | return nil, err | ||
| 15 | } | ||
| 16 | defer rows.Close() | ||
| 17 | out := map[string]int{} | ||
| 18 | for rows.Next() { | ||
| 19 | var id string | ||
| 20 | var number int | ||
| 21 | if err := rows.Scan(&id, &number); err != nil { | ||
| 22 | return nil, err | ||
| 23 | } | ||
| 24 | out[id] = number | ||
| 25 | } | ||
| 26 | return out, rows.Err() | ||
| 27 | } | ||
| 28 | |||
| 29 | // Number returns the alias for one entity and which kind it is. An entity the | ||
| 30 | // branch does not number (a stale index, or one that does not exist) reports | ||
| 31 | // ok=false rather than zero. | ||
| 32 | func (s *Store) Number(repoID, id string) (number int, kind string, ok bool) { | ||
| 33 | err := s.db.QueryRow(`SELECT number, kind FROM entity_numbers WHERE repo_id=? AND id=?`, repoID, id). | ||
| 34 | Scan(&number, &kind) | ||
| 35 | return number, kind, err == nil | ||
| 36 | } | ||
| 37 | |||
| 38 | // ByNumber resolves `#42` to the entity it names and its kind. Issues and change | ||
| 39 | // requests share one sequence, so the kind is part of the answer: the caller | ||
| 40 | // decides whether an issue or a request was asked for. | ||
| 41 | func (s *Store) ByNumber(repoID string, number int) (id, kind string, ok bool) { | ||
| 42 | err := s.db.QueryRow(`SELECT id, kind FROM entity_numbers WHERE repo_id=? AND number=?`, repoID, number). | ||
| 43 | Scan(&id, &kind) | ||
| 44 | return id, kind, err == nil | ||
| 45 | } | ||