github-repository-provider 7.30.13 → 7.30.14
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/package.json +2 -2
- package/src/github-branch.mjs +34 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.30.
|
|
3
|
+
"version": "7.30.14",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ava": "^4.3.0",
|
|
43
43
|
"c8": "^7.11.3",
|
|
44
44
|
"documentation": "^13.2.5",
|
|
45
|
-
"etag-cache-leveldb": "^1.2.
|
|
45
|
+
"etag-cache-leveldb": "^1.2.3",
|
|
46
46
|
"leveldown": "^6.1.1",
|
|
47
47
|
"levelup": "^5.1.1",
|
|
48
48
|
"repository-provider-test-support": "^2.2.5",
|
package/src/github-branch.mjs
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
* Branch on GitHub.
|
|
11
11
|
*/
|
|
12
12
|
export class GithubBranch extends Branch {
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* Writes content into the branch
|
|
16
15
|
* {@link https://developer.github.com/v3/git/blobs/#get-a-blob}
|
|
@@ -18,16 +17,17 @@ export class GithubBranch extends Branch {
|
|
|
18
17
|
* @return {Promise<ContentEntry>} written content with sha values set
|
|
19
18
|
*/
|
|
20
19
|
async writeEntry(entry) {
|
|
21
|
-
const { json } = await this.provider.fetchJSON(
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const { json } = await this.provider.fetchJSON(`${this.api}/git/blobs`, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
body: JSON.stringify({
|
|
23
|
+
content: await entry.string,
|
|
24
|
+
encoding: "utf8"
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (this.#entries) {
|
|
29
|
+
this.#entries.set(entry.name, entry);
|
|
30
|
+
}
|
|
31
31
|
|
|
32
32
|
entry.sha = json.sha;
|
|
33
33
|
|
|
@@ -58,23 +58,20 @@ export class GithubBranch extends Branch {
|
|
|
58
58
|
const shaLatestCommit = await this.refId();
|
|
59
59
|
const commit = await this.commitForSha(shaLatestCommit);
|
|
60
60
|
|
|
61
|
-
let { json } = await this.provider.fetchJSON(
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
mode: "100" + u.mode.toString(8)
|
|
73
|
-
};
|
|
74
|
-
})
|
|
61
|
+
let { json } = await this.provider.fetchJSON(`${this.api}/git/trees`, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: JSON.stringify({
|
|
64
|
+
base_tree: commit.tree.sha,
|
|
65
|
+
tree: updates.map(u => {
|
|
66
|
+
return {
|
|
67
|
+
path: u.name,
|
|
68
|
+
sha: u.sha,
|
|
69
|
+
type: "blob",
|
|
70
|
+
mode: "100" + u.mode.toString(8)
|
|
71
|
+
};
|
|
75
72
|
})
|
|
76
|
-
}
|
|
77
|
-
);
|
|
73
|
+
})
|
|
74
|
+
});
|
|
78
75
|
|
|
79
76
|
let r = await this.provider.fetchJSON(`${this.api}/git/commits`, {
|
|
80
77
|
method: "POST",
|
|
@@ -115,7 +112,9 @@ export class GithubBranch extends Branch {
|
|
|
115
112
|
}
|
|
116
113
|
|
|
117
114
|
const f = async () => {
|
|
118
|
-
const { json } = await this.provider.fetchJSON(
|
|
115
|
+
const { json } = await this.provider.fetchJSON(
|
|
116
|
+
`${this.api}/contents/${name}?ref=${this.ref}`
|
|
117
|
+
);
|
|
119
118
|
|
|
120
119
|
const entry = new this.entryClass(
|
|
121
120
|
name,
|
|
@@ -148,7 +147,9 @@ export class GithubBranch extends Branch {
|
|
|
148
147
|
this.#commitForSha = new Map();
|
|
149
148
|
}
|
|
150
149
|
|
|
151
|
-
const { json } = await this.provider.fetchJSON(
|
|
150
|
+
const { json } = await this.provider.fetchJSON(
|
|
151
|
+
`${this.api}/git/commits/${sha}`
|
|
152
|
+
);
|
|
152
153
|
|
|
153
154
|
this.#commitForSha.set(sha, json);
|
|
154
155
|
|
|
@@ -170,7 +171,9 @@ export class GithubBranch extends Branch {
|
|
|
170
171
|
this.#tree = new Map();
|
|
171
172
|
}
|
|
172
173
|
|
|
173
|
-
const { json } = await this.provider.fetchJSON(
|
|
174
|
+
const { json } = await this.provider.fetchJSON(
|
|
175
|
+
`${this.api}/git/trees/${sha}?recursive=1`
|
|
176
|
+
);
|
|
174
177
|
|
|
175
178
|
const tree = json.tree;
|
|
176
179
|
|
|
@@ -234,7 +237,7 @@ class LazyBufferContentEntry extends BufferContentEntryMixin(ContentEntry) {
|
|
|
234
237
|
}
|
|
235
238
|
|
|
236
239
|
#buffer;
|
|
237
|
-
|
|
240
|
+
|
|
238
241
|
async getBuffer() {
|
|
239
242
|
if (this.#buffer) {
|
|
240
243
|
return this.#buffer;
|