tangled
alpha
login
or
join now
evan.jarrett.net
/
at-container-registry
66
fork
atom
A container registry that uses the AT Protocol for manifest storage and S3 for blob storage.
atcr.io
docker
container
atproto
go
66
fork
atom
overview
issues
1
pulls
pipelines
implement HandleGetLatestCommit
evan.jarrett.net
1 month ago
0d00de76
22b2d69c
verified
This commit was signed with the committer's
known signature
.
evan.jarrett.net
SSH Key Fingerprint:
SHA256:bznk0uVPp7XFOl67P0uTM1pCjf2A4ojeP/lsUE7uauQ=
2/2
lint.yaml
success
4m 37s
tests.yml
success
4m 27s
+39
2 changed files
expand all
collapse all
unified
split
pkg
atproto
endpoints.go
hold
pds
xrpc.go
+6
pkg/atproto/endpoints.go
reviewed
···
135
135
// Response: {"did": "...", "active": true, "rev": "..."}
136
136
SyncGetRepoStatus = "/xrpc/com.atproto.sync.getRepoStatus"
137
137
138
138
+
// SyncGetLatestCommit gets the current commit CID and revision for a repository.
139
139
+
// Method: GET
140
140
+
// Query: did={did}
141
141
+
// Response: {"cid": "...", "rev": "..."}
142
142
+
SyncGetLatestCommit = "/xrpc/com.atproto.sync.getLatestCommit"
143
143
+
138
144
// SyncGetHostStatus gets the hosting/crawl status for a hostname on a relay.
139
145
// Method: GET
140
146
// Query: hostname={hostname}
+33
pkg/hold/pds/xrpc.go
reviewed
···
169
169
r.Get(atproto.SyncGetRecord, h.HandleSyncGetRecord)
170
170
r.Get(atproto.SyncGetRepo, h.HandleGetRepo)
171
171
r.Get(atproto.SyncGetRepoStatus, h.HandleGetRepoStatus)
172
172
+
r.Get(atproto.SyncGetLatestCommit, h.HandleGetLatestCommit)
172
173
r.Get(atproto.SyncSubscribeRepos, h.HandleSubscribeRepos)
173
174
174
175
// DID document and handle resolution
···
1291
1292
"did": did,
1292
1293
"active": true,
1293
1294
"rev": rev,
1295
1295
+
})
1296
1296
+
}
1297
1297
+
1298
1298
+
// HandleGetLatestCommit returns the current commit CID and revision for a repository.
1299
1299
+
// Spec: https://docs.bsky.app/docs/api/com-atproto-sync-get-latest-commit
1300
1300
+
func (h *XRPCHandler) HandleGetLatestCommit(w http.ResponseWriter, r *http.Request) {
1301
1301
+
did := r.URL.Query().Get("did")
1302
1302
+
if did == "" {
1303
1303
+
http.Error(w, "missing required parameter: did", http.StatusBadRequest)
1304
1304
+
return
1305
1305
+
}
1306
1306
+
1307
1307
+
if did != h.pds.DID() {
1308
1308
+
http.Error(w, "RepoNotFound", http.StatusNotFound)
1309
1309
+
return
1310
1310
+
}
1311
1311
+
1312
1312
+
head, err := h.pds.repomgr.GetRepoRoot(r.Context(), h.pds.uid)
1313
1313
+
if err != nil {
1314
1314
+
http.Error(w, "RepoNotFound", http.StatusNotFound)
1315
1315
+
return
1316
1316
+
}
1317
1317
+
1318
1318
+
rev, err := h.pds.repomgr.GetRepoRev(r.Context(), h.pds.uid)
1319
1319
+
if err != nil || rev == "" {
1320
1320
+
http.Error(w, "RepoNotFound", http.StatusNotFound)
1321
1321
+
return
1322
1322
+
}
1323
1323
+
1324
1324
+
render.JSON(w, r, map[string]any{
1325
1325
+
"cid": head.String(),
1326
1326
+
"rev": rev,
1294
1327
})
1295
1328
}
1296
1329