vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Phase 5: file locking, for the repositories git cannot merge
bf1e027ce09298d66cb8225fb1f5871e959f42bc · Keenan Nemetz · 16d ago · parent 21d48210
Phase 5: file locking, for the repositories git cannot merge `git lfs lock <path>` works over the SSH transfer, and while a path is held a push that changes it is refused. This is what makes a repository of design files usable by more than one person: two people pushing changes to the same binary leaves one version and silently discards the other, and "discarded" is not a conflict anybody can resolve. The HTTP locking API is the usual path for git-lfs, and it is a *write* surface, which this instance does not have — its web is anonymous and read-only. So locking rides the SSH transfer protocol instead (lock, list-lock, unlock, advertised as the `locking` capability): the key that pushed is the key that locks, with no second endpoint and nothing new to authenticate. The decision worth remembering is where the refusal lives. git-lfs enforces locks on the *client* — it asks the server what is held and declines to send the push — which is a courtesy, and a plain `git push` walks straight past it. So the rule also sits in pre-receive, at the one place this forge enforces everything else, where a client setting cannot turn it off. The client-side check becomes a faster error message rather than the authority. It guards only the paths the push actually writes, so reading, branching and merging untouched history are unaffected. An admin may override, audited, for the same reason force-push is allowed: a lock whose holder has left would otherwise make a path unpushable forever. Locks live in data/users.db beside the roster and the access rules — the file holding what git cannot rebuild — because a lock resurrected from history would be exactly wrong. The point of a lock is that it is released. They are keyed by account id, so a rename releases nothing, and path normalization makes "./art.psd" and "art.psd" one lock rather than two. /r/<repo>/locks answers "who is holding what", which the protocol otherwise hides completely: the next person to push is refused with no way to find out why without asking somebody. Measured: TestALockRefusesAPushUntilItIsReleased drives the whole lifecycle through the binary over SSH — lock, a refused push naming the holder, unlock, the same push landing — with git-lfs deliberately absent so the refusal can only come from pre-receive. TestLocksAreAdvertisedOnlyWhenOffered pins that the capability follows the lock table, since a client that reads `locking` will offer a command that must work. Store tests cover path normalization, paging, owner partitioning and the audited override. Known gap, stated rather than assumed: git-lfs is not installed here, so the protocol was written against docs/proposals/ssh_adapter.md and verified with a client written to that document — not with a shipped client. The framing, the 201/409 argument blocks and the five-line lock-spec records are the spec's; whether a real `git lfs lock` agrees is the first thing to check on a machine that has one.
internal/hook/hook.go +36−2
| @@ -17,6 +17,7 @@ import ( | |||
| 17 | 17 | "github.com/rodent-software/vole/internal/identity" | |
| 18 | 18 | "github.com/rodent-software/vole/internal/issues" | |
| 19 | 19 | "github.com/rodent-software/vole/internal/lfs" | |
| 20 | "github.com/rodent-software/vole/internal/locks" | ||
| 20 | 21 | "github.com/rodent-software/vole/internal/repo" | |
| 21 | 22 | "github.com/rodent-software/vole/internal/requests" | |
| 22 | 23 | "github.com/rodent-software/vole/internal/runs" | |
| @@ -67,8 +68,9 @@ func PreReceive(cfg Config) int { | |||
| 67 | 68 | // so the gate has to open the repository the same way the server does rather than | |
| 68 | 69 | // assume a directory is a repository. | |
| 69 | 70 | var ( | |
| 70 | acls *access.Store | ||
| 71 | err error | ||
| 71 | acls *access.Store | ||
| 72 | lockTable *locks.Store | ||
| 73 | err error | ||
| 72 | 74 | ) | |
| 73 | 75 | if cfg.UsersDB != "" { | |
| 74 | 76 | acls, err = access.Open(cfg.UsersDB) | |
| @@ -77,6 +79,14 @@ func PreReceive(cfg Config) int { | |||
| 77 | 79 | return 1 | |
| 78 | 80 | } | |
| 79 | 81 | defer acls.Close() | |
| 82 | // The lock table shares that database, so the push path learns what is held | ||
| 83 | // without a second endpoint and without the client's cooperation. | ||
| 84 | lockTable, err = locks.Open(cfg.UsersDB) | ||
| 85 | if err != nil { | ||
| 86 | reject(cfg.Out, "cannot open the lock table: %v", err) | ||
| 87 | return 1 | ||
| 88 | } | ||
| 89 | defer lockTable.Close() | ||
| 80 | 90 | } | |
| 81 | 91 | // GIT_DIR may be "." — that is what git hands a hook — so the directory is made | |
| 82 | 92 | // absolute before anything is derived from it. | |
| @@ -213,6 +223,30 @@ func PreReceive(cfg Config) int { | |||
| 213 | 223 | } | |
| 214 | 224 | } | |
| 215 | 225 | ||
| 226 | // An LFS lock is held on a path, and a push that changes that path is exactly | ||
| 227 | // what the holder asked to be told about. This sits with the integrity checks | ||
| 228 | // rather than with review: a lock is not a review decision, and an admin may | ||
| 229 | // override it, audited, because a lock whose holder has left would otherwise | ||
| 230 | // make a path unpushable forever. | ||
| 231 | if lockTable != nil { | ||
| 232 | held, err := lockTable.Paths(m.ID) | ||
| 233 | if err != nil { | ||
| 234 | problems = append(problems, fmt.Sprintf("%s: cannot read the lock table: %v", c.ref, err)) | ||
| 235 | } else if lockProblems, err := lockedPathFindings(g, c, held, actorID, who); err != nil { | ||
| 236 | problems = append(problems, fmt.Sprintf("%s: cannot check locks: %v", c.ref, err)) | ||
| 237 | } else if len(lockProblems) > 0 { | ||
| 238 | if role.AtLeast(acl.Admin) { | ||
| 239 | for _, p := range lockProblems { | ||
| 240 | auditLine(cfg.AuditPath, fmt.Sprintf("lock override %s by %s in %s: %s", | ||
| 241 | c.ref, actor, m.Name, p)) | ||
| 242 | reject(cfg.Out, "admin override, audited: %s", p) | ||
| 243 | } | ||
| 244 | } else { | ||
| 245 | problems = append(problems, lockProblems...) | ||
| 246 | } | ||
| 247 | } | ||
| 248 | } | ||
| 249 | |||
| 216 | 250 | // A published release is immutable: the tag that names it and the pointers | |
| 217 | 251 | // that carry its bytes. This sits with the integrity checks rather than | |
| 218 | 252 | // with the review gate, because a download that can change bytes is broken | |