Repository navigation
Commit 6d2d51d
refactor(api): reconcile through gitsheets repo.sync()
Swap reconcile.ts's hand-rolled merge-base / merge-tree / commit-tree /
update-ref / push plumbing for repo.sync({ onConflict:
'preserve-branch' }), and the webhook's rev-parse + merge-base
pre-check for repo.isAncestor. Outcome vocabulary and webhook response
are unchanged: gitsheets' 'ahead' maps to 'pushed-ahead' and the
conflict branch keeps the conflicts/<UTC> name.
repo.sync() takes its handle's write lock and throws lock_held inside
withLock, but the hot reload needs ref move + store refresh + rebuild
in one critical section, or a write queued on the lock can run in the
gap, validate against pre-reload in-memory state and clobber what the
reload brought in. So the serving repository's withLock still wraps
the whole reconcile, and sync runs through a short-lived side handle
on the same gitdir whose own lock is uncontended. The fetch stays a
separate lock-free step (sync can't fetch without locking).
A new test holds the lock, queues the reload and then a write behind
it, and asserts the ref doesn't move until the lock frees and no
commit lands before the rebuild; it fails for both sync-then-lock
variants.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Q2tgjZEUrtvVk6k8SpdXJ1 parent 601e87c commit 6d2d51d
5 files changed
Lines changed: 302 additions & 476 deletions
File tree
- apps/api
- src
- plugins
- routes
- store
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
77 | | - | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | | - | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | | - | |
41 | | - | |
42 | 38 | | |
43 | 39 | | |
44 | 40 | | |
| |||
146 | 142 | | |
147 | 143 | | |
148 | 144 | | |
149 | | - | |
150 | 145 | | |
151 | 146 | | |
152 | 147 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
158 | 153 | | |
159 | 154 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
182 | 170 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
187 | 174 | | |
188 | 175 | | |
189 | 176 | | |
| |||
0 commit comments