gip-remote 1.1.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -23,9 +23,12 @@ class Remote extends ReadyResource {
23
23
  if (typeof this._link === 'string') {
24
24
  this._name = this._link
25
25
  config = {}
26
- } else {
26
+ } else if (this._link.drive) {
27
27
  this._name = this._link.pathname?.split('/').slice(1)[0]
28
- config = this._link.drive
28
+ config = { key: this._link.drive.key }
29
+ } else {
30
+ this._name = this._link.name
31
+ config = this._link
29
32
  }
30
33
 
31
34
  const bee = new Hyperbee(store, config, { autoUpdate: true })
@@ -75,6 +78,16 @@ class Remote extends ReadyResource {
75
78
 
76
79
  // --- Refs / Branches ---
77
80
 
81
+ async getHead() {
82
+ const record = await this._db.get('@gip/head', {})
83
+ return record ? record.branch : null
84
+ }
85
+
86
+ async setHead(branch) {
87
+ await this._db.insert('@gip/head', { branch })
88
+ await this._db.flush()
89
+ }
90
+
78
91
  async getAllRefs() {
79
92
  const branches = this._db.find('@gip/branches')
80
93
  const refs = []
@@ -83,8 +96,11 @@ class Remote extends ReadyResource {
83
96
  refs.push({ ref: `refs/heads/${b.name}`, oid: b.commitOid })
84
97
  }
85
98
 
86
- const main = refs.find((r) => r.ref === 'refs/heads/main')
87
- if (main) refs.push({ ref: 'HEAD', oid: main.oid })
99
+ const headBranch = await this.getHead()
100
+ if (headBranch) {
101
+ const head = refs.find((r) => r.ref === `refs/heads/${headBranch}`)
102
+ if (head) refs.push({ ref: 'HEAD', symref: head.ref, oid: head.oid })
103
+ }
88
104
 
89
105
  return refs.reverse()
90
106
  }
@@ -162,7 +178,13 @@ class Remote extends ReadyResource {
162
178
  objects: [...objects.keys()]
163
179
  })
164
180
 
165
- // 6. Flush
181
+ // 6. Set HEAD to first branch pushed (like git init)
182
+ const currentHead = await this.getHead()
183
+ if (!currentHead) {
184
+ await this._db.insert('@gip/head', { branch: branchName })
185
+ }
186
+
187
+ // 7. Flush
166
188
  await this._db.flush()
167
189
  }
168
190
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gip-remote",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "Git+Pear remote DB for handling git data",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 1,
2
+ "version": 2,
3
3
  "offset": 0,
4
4
  "schema": [
5
5
  {
@@ -12,7 +12,9 @@
12
12
  "indexes": [],
13
13
  "schema": "@gip/repos",
14
14
  "derived": false,
15
- "key": ["name"],
15
+ "key": [
16
+ "name"
17
+ ],
16
18
  "trigger": null
17
19
  },
18
20
  {
@@ -25,7 +27,9 @@
25
27
  "indexes": [],
26
28
  "schema": "@gip/branches",
27
29
  "derived": false,
28
- "key": ["name"],
30
+ "key": [
31
+ "name"
32
+ ],
29
33
  "trigger": null
30
34
  },
31
35
  {
@@ -35,10 +39,15 @@
35
39
  "type": 1,
36
40
  "version": 1,
37
41
  "versionField": null,
38
- "indexes": ["@gip/files-by-branch"],
42
+ "indexes": [
43
+ "@gip/files-by-branch"
44
+ ],
39
45
  "schema": "@gip/files",
40
46
  "derived": false,
41
- "key": ["branch", "path"],
47
+ "key": [
48
+ "branch",
49
+ "path"
50
+ ],
42
51
  "trigger": null
43
52
  },
44
53
  {
@@ -51,7 +60,9 @@
51
60
  "indexes": [],
52
61
  "schema": "@gip/objects",
53
62
  "derived": false,
54
- "key": ["oid"],
63
+ "key": [
64
+ "oid"
65
+ ],
55
66
  "trigger": null
56
67
  },
57
68
  {
@@ -63,7 +74,22 @@
63
74
  "collection": "@gip/files",
64
75
  "unique": false,
65
76
  "deprecated": false,
66
- "key": ["branch"]
77
+ "key": [
78
+ "branch"
79
+ ]
80
+ },
81
+ {
82
+ "name": "head",
83
+ "namespace": "gip",
84
+ "id": 5,
85
+ "type": 1,
86
+ "version": 2,
87
+ "versionField": null,
88
+ "indexes": [],
89
+ "schema": "@gip/head",
90
+ "derived": false,
91
+ "key": [],
92
+ "trigger": null
67
93
  }
68
94
  ]
69
- }
95
+ }
@@ -4,12 +4,14 @@
4
4
  const { IndexEncoder, c, b4a } = require('hyperdb/runtime')
5
5
  const { version, getEncoding, setVersion } = require('./messages.js')
6
6
 
7
- const versions = { schema: version, db: 1 }
7
+ const versions = { schema: version, db: 2 }
8
8
 
9
9
  // '@gip/repos' collection key
10
- const collection0_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 0 })
10
+ const collection0_key = new IndexEncoder([
11
+ IndexEncoder.STRING
12
+ ], { prefix: 0 })
11
13
 
12
- function collection0_indexify(record) {
14
+ function collection0_indexify (record) {
13
15
  const a = record.name
14
16
  return a === undefined ? [] : [a]
15
17
  }
@@ -18,7 +20,7 @@ function collection0_indexify(record) {
18
20
  const collection0_enc = getEncoding('@gip/repos/hyperdb#0')
19
21
 
20
22
  // '@gip/repos' reconstruction function
21
- function collection0_reconstruct(schemaVersion, keyBuf, valueBuf) {
23
+ function collection0_reconstruct (schemaVersion, keyBuf, valueBuf) {
22
24
  const key = collection0_key.decode(keyBuf)
23
25
  setVersion(schemaVersion)
24
26
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -30,7 +32,7 @@ function collection0_reconstruct(schemaVersion, keyBuf, valueBuf) {
30
32
  return record
31
33
  }
32
34
  // '@gip/repos' key reconstruction function
33
- function collection0_reconstruct_key(keyBuf) {
35
+ function collection0_reconstruct_key (keyBuf) {
34
36
  const key = collection0_key.decode(keyBuf)
35
37
  return {
36
38
  name: key[0]
@@ -42,11 +44,11 @@ const collection0 = {
42
44
  name: '@gip/repos',
43
45
  id: 0,
44
46
  version: 1,
45
- encodeKey(record) {
47
+ encodeKey (record) {
46
48
  const key = [record.name]
47
49
  return collection0_key.encode(key)
48
50
  },
49
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
51
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
50
52
  return collection0_key.encodeRange({
51
53
  gt: gt ? collection0_indexify(gt) : null,
52
54
  lt: lt ? collection0_indexify(lt) : null,
@@ -54,7 +56,7 @@ const collection0 = {
54
56
  lte: lte ? collection0_indexify(lte) : null
55
57
  })
56
58
  },
57
- encodeValue(schemaVersion, collectionVersion, record) {
59
+ encodeValue (schemaVersion, collectionVersion, record) {
58
60
  setVersion(schemaVersion)
59
61
  const state = { start: 0, end: 2, buffer: null }
60
62
  collection0_enc.preencode(state, record)
@@ -72,9 +74,11 @@ const collection0 = {
72
74
  }
73
75
 
74
76
  // '@gip/branches' collection key
75
- const collection1_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 1 })
77
+ const collection1_key = new IndexEncoder([
78
+ IndexEncoder.STRING
79
+ ], { prefix: 1 })
76
80
 
77
- function collection1_indexify(record) {
81
+ function collection1_indexify (record) {
78
82
  const a = record.name
79
83
  return a === undefined ? [] : [a]
80
84
  }
@@ -83,7 +87,7 @@ function collection1_indexify(record) {
83
87
  const collection1_enc = getEncoding('@gip/branches/hyperdb#1')
84
88
 
85
89
  // '@gip/branches' reconstruction function
86
- function collection1_reconstruct(schemaVersion, keyBuf, valueBuf) {
90
+ function collection1_reconstruct (schemaVersion, keyBuf, valueBuf) {
87
91
  const key = collection1_key.decode(keyBuf)
88
92
  setVersion(schemaVersion)
89
93
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -95,7 +99,7 @@ function collection1_reconstruct(schemaVersion, keyBuf, valueBuf) {
95
99
  return record
96
100
  }
97
101
  // '@gip/branches' key reconstruction function
98
- function collection1_reconstruct_key(keyBuf) {
102
+ function collection1_reconstruct_key (keyBuf) {
99
103
  const key = collection1_key.decode(keyBuf)
100
104
  return {
101
105
  name: key[0]
@@ -107,11 +111,11 @@ const collection1 = {
107
111
  name: '@gip/branches',
108
112
  id: 1,
109
113
  version: 1,
110
- encodeKey(record) {
114
+ encodeKey (record) {
111
115
  const key = [record.name]
112
116
  return collection1_key.encode(key)
113
117
  },
114
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
118
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
115
119
  return collection1_key.encodeRange({
116
120
  gt: gt ? collection1_indexify(gt) : null,
117
121
  lt: lt ? collection1_indexify(lt) : null,
@@ -119,7 +123,7 @@ const collection1 = {
119
123
  lte: lte ? collection1_indexify(lte) : null
120
124
  })
121
125
  },
122
- encodeValue(schemaVersion, collectionVersion, record) {
126
+ encodeValue (schemaVersion, collectionVersion, record) {
123
127
  setVersion(schemaVersion)
124
128
  const state = { start: 0, end: 2, buffer: null }
125
129
  collection1_enc.preencode(state, record)
@@ -137,9 +141,12 @@ const collection1 = {
137
141
  }
138
142
 
139
143
  // '@gip/files' collection key
140
- const collection2_key = new IndexEncoder([IndexEncoder.STRING, IndexEncoder.STRING], { prefix: 2 })
144
+ const collection2_key = new IndexEncoder([
145
+ IndexEncoder.STRING,
146
+ IndexEncoder.STRING
147
+ ], { prefix: 2 })
141
148
 
142
- function collection2_indexify(record) {
149
+ function collection2_indexify (record) {
143
150
  const arr = []
144
151
 
145
152
  const a0 = record.branch
@@ -157,7 +164,7 @@ function collection2_indexify(record) {
157
164
  const collection2_enc = getEncoding('@gip/files/hyperdb#2')
158
165
 
159
166
  // '@gip/files' reconstruction function
160
- function collection2_reconstruct(schemaVersion, keyBuf, valueBuf) {
167
+ function collection2_reconstruct (schemaVersion, keyBuf, valueBuf) {
161
168
  const key = collection2_key.decode(keyBuf)
162
169
  setVersion(schemaVersion)
163
170
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -170,7 +177,7 @@ function collection2_reconstruct(schemaVersion, keyBuf, valueBuf) {
170
177
  return record
171
178
  }
172
179
  // '@gip/files' key reconstruction function
173
- function collection2_reconstruct_key(keyBuf) {
180
+ function collection2_reconstruct_key (keyBuf) {
174
181
  const key = collection2_key.decode(keyBuf)
175
182
  return {
176
183
  branch: key[0],
@@ -183,11 +190,11 @@ const collection2 = {
183
190
  name: '@gip/files',
184
191
  id: 2,
185
192
  version: 1,
186
- encodeKey(record) {
193
+ encodeKey (record) {
187
194
  const key = [record.branch, record.path]
188
195
  return collection2_key.encode(key)
189
196
  },
190
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
197
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
191
198
  return collection2_key.encodeRange({
192
199
  gt: gt ? collection2_indexify(gt) : null,
193
200
  lt: lt ? collection2_indexify(lt) : null,
@@ -195,7 +202,7 @@ const collection2 = {
195
202
  lte: lte ? collection2_indexify(lte) : null
196
203
  })
197
204
  },
198
- encodeValue(schemaVersion, collectionVersion, record) {
205
+ encodeValue (schemaVersion, collectionVersion, record) {
199
206
  setVersion(schemaVersion)
200
207
  const state = { start: 0, end: 2, buffer: null }
201
208
  collection2_enc.preencode(state, record)
@@ -213,9 +220,11 @@ const collection2 = {
213
220
  }
214
221
 
215
222
  // '@gip/objects' collection key
216
- const collection3_key = new IndexEncoder([IndexEncoder.STRING], { prefix: 3 })
223
+ const collection3_key = new IndexEncoder([
224
+ IndexEncoder.STRING
225
+ ], { prefix: 3 })
217
226
 
218
- function collection3_indexify(record) {
227
+ function collection3_indexify (record) {
219
228
  const a = record.oid
220
229
  return a === undefined ? [] : [a]
221
230
  }
@@ -224,7 +233,7 @@ function collection3_indexify(record) {
224
233
  const collection3_enc = getEncoding('@gip/objects/hyperdb#3')
225
234
 
226
235
  // '@gip/objects' reconstruction function
227
- function collection3_reconstruct(schemaVersion, keyBuf, valueBuf) {
236
+ function collection3_reconstruct (schemaVersion, keyBuf, valueBuf) {
228
237
  const key = collection3_key.decode(keyBuf)
229
238
  setVersion(schemaVersion)
230
239
  const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
@@ -236,7 +245,7 @@ function collection3_reconstruct(schemaVersion, keyBuf, valueBuf) {
236
245
  return record
237
246
  }
238
247
  // '@gip/objects' key reconstruction function
239
- function collection3_reconstruct_key(keyBuf) {
248
+ function collection3_reconstruct_key (keyBuf) {
240
249
  const key = collection3_key.decode(keyBuf)
241
250
  return {
242
251
  oid: key[0]
@@ -248,11 +257,11 @@ const collection3 = {
248
257
  name: '@gip/objects',
249
258
  id: 3,
250
259
  version: 1,
251
- encodeKey(record) {
260
+ encodeKey (record) {
252
261
  const key = [record.oid]
253
262
  return collection3_key.encode(key)
254
263
  },
255
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
264
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
256
265
  return collection3_key.encodeRange({
257
266
  gt: gt ? collection3_indexify(gt) : null,
258
267
  lt: lt ? collection3_indexify(lt) : null,
@@ -260,7 +269,7 @@ const collection3 = {
260
269
  lte: lte ? collection3_indexify(lte) : null
261
270
  })
262
271
  },
263
- encodeValue(schemaVersion, collectionVersion, record) {
272
+ encodeValue (schemaVersion, collectionVersion, record) {
264
273
  setVersion(schemaVersion)
265
274
  const state = { start: 0, end: 2, buffer: null }
266
275
  collection3_enc.preencode(state, record)
@@ -278,12 +287,13 @@ const collection3 = {
278
287
  }
279
288
 
280
289
  // '@gip/files-by-branch' collection key
281
- const index4_key = new IndexEncoder(
282
- [IndexEncoder.STRING, IndexEncoder.STRING, IndexEncoder.STRING],
283
- { prefix: 4 }
284
- )
290
+ const index4_key = new IndexEncoder([
291
+ IndexEncoder.STRING,
292
+ IndexEncoder.STRING,
293
+ IndexEncoder.STRING
294
+ ], { prefix: 4 })
285
295
 
286
- function index4_indexify(record) {
296
+ function index4_indexify (record) {
287
297
  const arr = []
288
298
 
289
299
  const a0 = record.branch
@@ -306,10 +316,10 @@ const index4 = {
306
316
  name: '@gip/files-by-branch',
307
317
  version: 1,
308
318
  id: 4,
309
- encodeKey(record) {
319
+ encodeKey (record) {
310
320
  return index4_key.encode(index4_indexify(record))
311
321
  },
312
- encodeKeyRange({ gt, lt, gte, lte } = {}) {
322
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
313
323
  return index4_key.encodeRange({
314
324
  gt: gt ? index4_indexify(gt) : null,
315
325
  lt: lt ? index4_indexify(lt) : null,
@@ -318,7 +328,7 @@ const index4 = {
318
328
  })
319
329
  },
320
330
  encodeValue: (record) => index4.collection.encodeKey(record),
321
- encodeIndexKeys(record, context) {
331
+ encodeIndexKeys (record, context) {
322
332
  return [index4_key.encode([record.branch, record.branch, record.path])]
323
333
  },
324
334
  reconstruct: (keyBuf, valueBuf) => valueBuf,
@@ -327,32 +337,94 @@ const index4 = {
327
337
  }
328
338
  collection2.indexes.push(index4)
329
339
 
330
- const collections = [collection0, collection1, collection2, collection3]
340
+ // '@gip/head' collection key
341
+ const collection5_key = new IndexEncoder([
342
+ ], { prefix: 5 })
331
343
 
332
- const indexes = [index4]
344
+ function collection5_indexify (record) {
345
+ return []
346
+ }
347
+
348
+ // '@gip/head' value encoding
349
+ const collection5_enc = getEncoding('@gip/head')
350
+
351
+ // '@gip/head' reconstruction function
352
+ function collection5_reconstruct (schemaVersion, keyBuf, valueBuf) {
353
+ setVersion(schemaVersion)
354
+ const state = { start: 0, end: valueBuf.byteLength, buffer: valueBuf }
355
+ const type = c.uint.decode(state)
356
+ if (type !== 0) throw new Error('Unknown collection type: ' + type)
357
+ collection5.decodedVersion = c.uint.decode(state)
358
+ const record = collection5_enc.decode(state)
359
+ return record
360
+ }
361
+ // '@gip/head' key reconstruction function
362
+ function collection5_reconstruct_key (keyBuf) {
363
+ return {}
364
+ }
365
+
366
+ // '@gip/head'
367
+ const collection5 = {
368
+ name: '@gip/head',
369
+ id: 5,
370
+ version: 2,
371
+ encodeKey (record) {
372
+ const key = []
373
+ return collection5_key.encode(key)
374
+ },
375
+ encodeKeyRange ({ gt, lt, gte, lte } = {}) {
376
+ return collection5_key.encodeRange({
377
+ gt: gt ? collection5_indexify(gt) : null,
378
+ lt: lt ? collection5_indexify(lt) : null,
379
+ gte: gte ? collection5_indexify(gte) : null,
380
+ lte: lte ? collection5_indexify(lte) : null
381
+ })
382
+ },
383
+ encodeValue (schemaVersion, collectionVersion, record) {
384
+ setVersion(schemaVersion)
385
+ const state = { start: 0, end: 2, buffer: null }
386
+ collection5_enc.preencode(state, record)
387
+ state.buffer = b4a.allocUnsafe(state.end)
388
+ state.buffer[state.start++] = 0
389
+ state.buffer[state.start++] = collectionVersion
390
+ collection5_enc.encode(state, record)
391
+ return state.buffer
392
+ },
393
+ trigger: null,
394
+ reconstruct: collection5_reconstruct,
395
+ reconstructKey: collection5_reconstruct_key,
396
+ indexes: [],
397
+ decodedVersion: 0
398
+ }
399
+
400
+ const collections = [
401
+ collection0,
402
+ collection1,
403
+ collection2,
404
+ collection3,
405
+ collection5
406
+ ]
407
+
408
+ const indexes = [
409
+ index4
410
+ ]
333
411
 
334
412
  module.exports = { versions, collections, indexes, resolveCollection, resolveIndex }
335
413
 
336
- function resolveCollection(name) {
414
+ function resolveCollection (name) {
337
415
  switch (name) {
338
- case '@gip/repos':
339
- return collection0
340
- case '@gip/branches':
341
- return collection1
342
- case '@gip/files':
343
- return collection2
344
- case '@gip/objects':
345
- return collection3
346
- default:
347
- return null
416
+ case '@gip/repos': return collection0
417
+ case '@gip/branches': return collection1
418
+ case '@gip/files': return collection2
419
+ case '@gip/objects': return collection3
420
+ case '@gip/head': return collection5
421
+ default: return null
348
422
  }
349
423
  }
350
424
 
351
- function resolveIndex(name) {
425
+ function resolveIndex (name) {
352
426
  switch (name) {
353
- case '@gip/files-by-branch':
354
- return index4
355
- default:
356
- return null
427
+ case '@gip/files-by-branch': return index4
428
+ default: return null
357
429
  }
358
430
  }
@@ -1,12 +1,12 @@
1
1
  // This file is autogenerated by the hyperschema compiler
2
- // Schema Version: 1
2
+ // Schema Version: 2
3
3
  /* eslint-disable camelcase */
4
4
  /* eslint-disable quotes */
5
5
  /* eslint-disable space-before-function-paren */
6
6
 
7
7
  const { c } = require('hyperschema/runtime')
8
8
 
9
- const VERSION = 1
9
+ const VERSION = 2
10
10
 
11
11
  // eslint-disable-next-line no-unused-vars
12
12
  let version = VERSION
@@ -151,10 +151,10 @@ const encoding3_enum = {
151
151
 
152
152
  // @gip/object-type enum
153
153
  const encoding3 = {
154
- preencode(state, m) {
154
+ preencode (state, m) {
155
155
  state.end++ // max enum is 4 so always one byte
156
156
  },
157
- encode(state, m) {
157
+ encode (state, m) {
158
158
  switch (m) {
159
159
  case 'blob':
160
160
  c.uint.encode(state, 1)
@@ -172,7 +172,7 @@ const encoding3 = {
172
172
  throw new Error('Unknown enum')
173
173
  }
174
174
  },
175
- decode(state) {
175
+ decode (state) {
176
176
  switch (c.uint.decode(state)) {
177
177
  case 1:
178
178
  return 'blob'
@@ -182,8 +182,7 @@ const encoding3 = {
182
182
  return 'commit'
183
183
  case 4:
184
184
  return 'tag'
185
- default:
186
- return null
185
+ default: return null
187
186
  }
188
187
  }
189
188
  }
@@ -217,8 +216,25 @@ const encoding4 = {
217
216
  }
218
217
  }
219
218
 
220
- // @gip/repos/hyperdb#0
219
+ // @gip/head
221
220
  const encoding5 = {
221
+ preencode(state, m) {
222
+ c.string.preencode(state, m.branch)
223
+ },
224
+ encode(state, m) {
225
+ c.string.encode(state, m.branch)
226
+ },
227
+ decode(state) {
228
+ const r0 = c.string.decode(state)
229
+
230
+ return {
231
+ branch: r0
232
+ }
233
+ }
234
+ }
235
+
236
+ // @gip/repos/hyperdb#0
237
+ const encoding6 = {
222
238
  preencode(state, m) {
223
239
  c.buffer.preencode(state, m.key)
224
240
  state.end++ // flags are fixed size
@@ -249,10 +265,10 @@ const encoding5 = {
249
265
  }
250
266
 
251
267
  // @gip/branches/hyperdb#1.objects
252
- const encoding6_6 = encoding1_6
268
+ const encoding7_6 = encoding1_6
253
269
 
254
270
  // @gip/branches/hyperdb#1
255
- const encoding6 = {
271
+ const encoding7 = {
256
272
  preencode(state, m) {
257
273
  c.string.preencode(state, m.commitOid)
258
274
  c.string.preencode(state, m.treeOid)
@@ -261,7 +277,7 @@ const encoding6 = {
261
277
  if (m.author) c.string.preencode(state, m.author)
262
278
  if (m.message) c.string.preencode(state, m.message)
263
279
  if (m.timestamp) c.uint.preencode(state, m.timestamp)
264
- if (m.objects) encoding6_6.preencode(state, m.objects)
280
+ if (m.objects) encoding7_6.preencode(state, m.objects)
265
281
  },
266
282
  encode(state, m) {
267
283
  const flags =
@@ -274,7 +290,7 @@ const encoding6 = {
274
290
  if (m.author) c.string.encode(state, m.author)
275
291
  if (m.message) c.string.encode(state, m.message)
276
292
  if (m.timestamp) c.uint.encode(state, m.timestamp)
277
- if (m.objects) encoding6_6.encode(state, m.objects)
293
+ if (m.objects) encoding7_6.encode(state, m.objects)
278
294
  },
279
295
  decode(state) {
280
296
  const r1 = c.string.decode(state)
@@ -288,13 +304,13 @@ const encoding6 = {
288
304
  author: (flags & 1) !== 0 ? c.string.decode(state) : null,
289
305
  message: (flags & 2) !== 0 ? c.string.decode(state) : null,
290
306
  timestamp: (flags & 4) !== 0 ? c.uint.decode(state) : 0,
291
- objects: (flags & 8) !== 0 ? encoding6_6.decode(state) : null
307
+ objects: (flags & 8) !== 0 ? encoding7_6.decode(state) : null
292
308
  }
293
309
  }
294
310
  }
295
311
 
296
312
  // @gip/files/hyperdb#2
297
- const encoding7 = {
313
+ const encoding8 = {
298
314
  preencode(state, m) {
299
315
  c.string.preencode(state, m.oid)
300
316
  c.string.preencode(state, m.mode)
@@ -337,7 +353,7 @@ const encoding7 = {
337
353
  }
338
354
 
339
355
  // @gip/objects/hyperdb#3
340
- const encoding8 = {
356
+ const encoding9 = {
341
357
  preencode(state, m) {
342
358
  encoding3.preencode(state, m.type)
343
359
  c.uint.preencode(state, m.size)
@@ -397,14 +413,16 @@ function getEncoding(name) {
397
413
  return encoding3
398
414
  case '@gip/objects':
399
415
  return encoding4
400
- case '@gip/repos/hyperdb#0':
416
+ case '@gip/head':
401
417
  return encoding5
402
- case '@gip/branches/hyperdb#1':
418
+ case '@gip/repos/hyperdb#0':
403
419
  return encoding6
404
- case '@gip/files/hyperdb#2':
420
+ case '@gip/branches/hyperdb#1':
405
421
  return encoding7
406
- case '@gip/objects/hyperdb#3':
422
+ case '@gip/files/hyperdb#2':
407
423
  return encoding8
424
+ case '@gip/objects/hyperdb#3':
425
+ return encoding9
408
426
  default:
409
427
  throw new Error('Encoder not found ' + name)
410
428
  }
@@ -1,12 +1,12 @@
1
1
  // This file is autogenerated by the hyperschema compiler
2
- // Schema Version: 1
2
+ // Schema Version: 2
3
3
  /* eslint-disable camelcase */
4
4
  /* eslint-disable quotes */
5
5
  /* eslint-disable space-before-function-paren */
6
6
 
7
7
  const { c } = require('hyperschema/runtime')
8
8
 
9
- const VERSION = 1
9
+ const VERSION = 2
10
10
 
11
11
  // eslint-disable-next-line no-unused-vars
12
12
  let version = VERSION
@@ -151,10 +151,10 @@ const encoding3_enum = {
151
151
 
152
152
  // @gip/object-type enum
153
153
  const encoding3 = {
154
- preencode(state, m) {
154
+ preencode (state, m) {
155
155
  state.end++ // max enum is 4 so always one byte
156
156
  },
157
- encode(state, m) {
157
+ encode (state, m) {
158
158
  switch (m) {
159
159
  case 'blob':
160
160
  c.uint.encode(state, 1)
@@ -172,7 +172,7 @@ const encoding3 = {
172
172
  throw new Error('Unknown enum')
173
173
  }
174
174
  },
175
- decode(state) {
175
+ decode (state) {
176
176
  switch (c.uint.decode(state)) {
177
177
  case 1:
178
178
  return 'blob'
@@ -182,8 +182,7 @@ const encoding3 = {
182
182
  return 'commit'
183
183
  case 4:
184
184
  return 'tag'
185
- default:
186
- return null
185
+ default: return null
187
186
  }
188
187
  }
189
188
  }
@@ -217,6 +216,23 @@ const encoding4 = {
217
216
  }
218
217
  }
219
218
 
219
+ // @gip/head
220
+ const encoding5 = {
221
+ preencode(state, m) {
222
+ c.string.preencode(state, m.branch)
223
+ },
224
+ encode(state, m) {
225
+ c.string.encode(state, m.branch)
226
+ },
227
+ decode(state) {
228
+ const r0 = c.string.decode(state)
229
+
230
+ return {
231
+ branch: r0
232
+ }
233
+ }
234
+ }
235
+
220
236
  function setVersion(v) {
221
237
  version = v
222
238
  }
@@ -252,6 +268,8 @@ function getEncoding(name) {
252
268
  return encoding3
253
269
  case '@gip/objects':
254
270
  return encoding4
271
+ case '@gip/head':
272
+ return encoding5
255
273
  default:
256
274
  throw new Error('Encoder not found ' + name)
257
275
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 1,
2
+ "version": 2,
3
3
  "schema": [
4
4
  {
5
5
  "name": "repos",
@@ -194,6 +194,20 @@
194
194
  "version": 1
195
195
  }
196
196
  ]
197
+ },
198
+ {
199
+ "name": "head",
200
+ "namespace": "gip",
201
+ "compact": true,
202
+ "flagsPosition": -1,
203
+ "fields": [
204
+ {
205
+ "name": "branch",
206
+ "required": true,
207
+ "type": "string",
208
+ "version": 2
209
+ }
210
+ ]
197
211
  }
198
212
  ]
199
213
  }