gip-remote 1.0.1 → 1.1.0
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 +25 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const ReadyResource = require('ready-resource')
|
|
2
2
|
const HyperDB = require('hyperdb')
|
|
3
3
|
const Hyperbee = require('hyperbee2')
|
|
4
|
+
const z32 = require('z32')
|
|
4
5
|
const def = require('./schema/hyperdb/index')
|
|
5
6
|
const RemoteDrive = require('./lib/drive')
|
|
6
7
|
const GitPearLink = require('./lib/link')
|
|
@@ -38,19 +39,27 @@ class Remote extends ReadyResource {
|
|
|
38
39
|
get name() {
|
|
39
40
|
return this._name
|
|
40
41
|
}
|
|
42
|
+
|
|
41
43
|
get core() {
|
|
42
44
|
return this._db.core
|
|
43
45
|
}
|
|
46
|
+
|
|
44
47
|
get key() {
|
|
45
48
|
return this._db.core.key
|
|
46
49
|
}
|
|
50
|
+
|
|
47
51
|
get discoveryKey() {
|
|
48
52
|
return this._db.core.discoveryKey
|
|
49
53
|
}
|
|
54
|
+
|
|
50
55
|
get availablePeers() {
|
|
51
56
|
return this._db.core.peers.length
|
|
52
57
|
}
|
|
53
58
|
|
|
59
|
+
get url() {
|
|
60
|
+
return `git+pear://${z32.encode(this.key)}/${this.name}`
|
|
61
|
+
}
|
|
62
|
+
|
|
54
63
|
// --- Objects ---
|
|
55
64
|
|
|
56
65
|
async getObject(oid) {
|
|
@@ -79,6 +88,22 @@ class Remote extends ReadyResource {
|
|
|
79
88
|
return { ref: `refs/heads/${b.name}`, oid: b.commitOid }
|
|
80
89
|
}
|
|
81
90
|
|
|
91
|
+
async deleteBranch(branchName) {
|
|
92
|
+
const branch = await this._db.get('@gip/branches', { name: branchName })
|
|
93
|
+
if (!branch) return false
|
|
94
|
+
|
|
95
|
+
await this._db.delete('@gip/branches', { name: branchName })
|
|
96
|
+
|
|
97
|
+
// Remove file records for this branch
|
|
98
|
+
const files = this._db.find('@gip/files', { branch: branchName })
|
|
99
|
+
for await (const file of files) {
|
|
100
|
+
await this._db.delete('@gip/files', { branch: branchName, path: file.path })
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
await this._db.flush()
|
|
104
|
+
return true
|
|
105
|
+
}
|
|
106
|
+
|
|
82
107
|
// --- Push: store objects + index branch + files ---
|
|
83
108
|
|
|
84
109
|
async push(branchName, commitOid, objects) {
|