github-repository-provider 7.27.0 → 7.28.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/package.json +4 -4
- package/src/github-branch.mjs +15 -15
- package/src/github-repository.mjs +9 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.28.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"content-entry": "^5.0.1",
|
|
34
34
|
"fetch-link-util": "^1.0.8",
|
|
35
|
-
"fetch-rate-limit-util": "^2.10.
|
|
35
|
+
"fetch-rate-limit-util": "^2.10.3",
|
|
36
36
|
"matching-iterator": "^2.0.4",
|
|
37
37
|
"node-fetch": "^3.2.4",
|
|
38
38
|
"one-time-execution-method": "^3.0.1",
|
|
39
|
-
"repository-provider": "^
|
|
39
|
+
"repository-provider": "^30.0.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"ava": "^4.2.0",
|
|
43
43
|
"c8": "^7.11.3",
|
|
44
44
|
"documentation": "^13.2.5",
|
|
45
|
-
"repository-provider-test-support": "^2.1.
|
|
45
|
+
"repository-provider-test-support": "^2.1.20",
|
|
46
46
|
"semantic-release": "^19.0.2"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
package/src/github-branch.mjs
CHANGED
|
@@ -10,6 +10,12 @@ import {
|
|
|
10
10
|
* Branch on GitHub.
|
|
11
11
|
*/
|
|
12
12
|
export class GithubBranch extends Branch {
|
|
13
|
+
|
|
14
|
+
get api()
|
|
15
|
+
{
|
|
16
|
+
return this.repository.api;
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
/**
|
|
14
20
|
* Writes content into the branch
|
|
15
21
|
* {@link https://developer.github.com/v3/git/blobs/#get-a-blob}
|
|
@@ -18,7 +24,7 @@ export class GithubBranch extends Branch {
|
|
|
18
24
|
*/
|
|
19
25
|
async writeEntry(entry) {
|
|
20
26
|
const { json } = await this.provider.fetchJSON(
|
|
21
|
-
|
|
27
|
+
`${this.api}/git/blobs`,
|
|
22
28
|
{
|
|
23
29
|
method: "POST",
|
|
24
30
|
body: JSON.stringify({
|
|
@@ -58,7 +64,7 @@ export class GithubBranch extends Branch {
|
|
|
58
64
|
const commit = await this.commitForSha(shaLatestCommit);
|
|
59
65
|
|
|
60
66
|
let { json } = await this.provider.fetchJSON(
|
|
61
|
-
|
|
67
|
+
`${this.api}/git/trees`,
|
|
62
68
|
{
|
|
63
69
|
method: "POST",
|
|
64
70
|
body: JSON.stringify({
|
|
@@ -75,7 +81,7 @@ export class GithubBranch extends Branch {
|
|
|
75
81
|
}
|
|
76
82
|
);
|
|
77
83
|
|
|
78
|
-
let r = await this.provider.fetchJSON(
|
|
84
|
+
let r = await this.provider.fetchJSON(`${this.api}/git/commits`, {
|
|
79
85
|
method: "POST",
|
|
80
86
|
body: JSON.stringify({
|
|
81
87
|
message,
|
|
@@ -84,7 +90,7 @@ export class GithubBranch extends Branch {
|
|
|
84
90
|
})
|
|
85
91
|
});
|
|
86
92
|
|
|
87
|
-
r = await this.provider.fetchJSON(
|
|
93
|
+
r = await this.provider.fetchJSON(`${this.api}/git/${this.ref}`, {
|
|
88
94
|
method: "PATCH",
|
|
89
95
|
body: JSON.stringify({
|
|
90
96
|
...options,
|
|
@@ -114,9 +120,7 @@ export class GithubBranch extends Branch {
|
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
const f = async () => {
|
|
117
|
-
const { json } = await this.provider.fetchJSON(
|
|
118
|
-
`repos/${this.slug}/contents/${name}?ref=${this.ref}`
|
|
119
|
-
);
|
|
123
|
+
const { json } = await this.provider.fetchJSON(`${this.api}/contents/${name}?ref=${this.ref}`);
|
|
120
124
|
|
|
121
125
|
const entry = new this.entryClass(
|
|
122
126
|
name,
|
|
@@ -149,9 +153,7 @@ export class GithubBranch extends Branch {
|
|
|
149
153
|
this.#commitForSha = new Map();
|
|
150
154
|
}
|
|
151
155
|
|
|
152
|
-
const { json } = await this.provider.fetchJSON(
|
|
153
|
-
`repos/${this.slug}/git/commits/${sha}`
|
|
154
|
-
);
|
|
156
|
+
const { json } = await this.provider.fetchJSON(`${this.api}/git/commits/${sha}`);
|
|
155
157
|
|
|
156
158
|
this.#commitForSha.set(sha, json);
|
|
157
159
|
|
|
@@ -173,9 +175,7 @@ export class GithubBranch extends Branch {
|
|
|
173
175
|
this.#tree = new Map();
|
|
174
176
|
}
|
|
175
177
|
|
|
176
|
-
const { json } = await this.provider.fetchJSON(
|
|
177
|
-
`repos/${this.slug}/git/trees/${sha}?recursive=1`
|
|
178
|
-
);
|
|
178
|
+
const { json } = await this.provider.fetchJSON(`${this.api}/git/trees/${sha}?recursive=1`);
|
|
179
179
|
|
|
180
180
|
const tree = json.tree;
|
|
181
181
|
|
|
@@ -219,7 +219,7 @@ export class GithubBranch extends Branch {
|
|
|
219
219
|
*/
|
|
220
220
|
async removeEntries(entries) {
|
|
221
221
|
for await (const entry of entries) {
|
|
222
|
-
await this.provider.fetch(
|
|
222
|
+
await this.provider.fetch(`${this.api}/contents/${entry.name}`, {
|
|
223
223
|
method: "DELETE",
|
|
224
224
|
body: JSON.stringify({ branch: this.name, message: "", sha: "" })
|
|
225
225
|
});
|
|
@@ -249,7 +249,7 @@ class LazyBufferContentEntry extends BufferContentEntryMixin(ContentEntry) {
|
|
|
249
249
|
|
|
250
250
|
const f = async () => {
|
|
251
251
|
const { json } = await branch.provider.fetchJSON(
|
|
252
|
-
|
|
252
|
+
`${branch.api}/contents/${this.name}?ref=${branch.ref}`
|
|
253
253
|
);
|
|
254
254
|
|
|
255
255
|
this.#buffer = Buffer.from(json.content, "base64");
|
|
@@ -39,6 +39,9 @@ export class GithubRepository extends Repository {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @return {string} "main"
|
|
44
|
+
*/
|
|
42
45
|
get defaultBranchName() {
|
|
43
46
|
return "main";
|
|
44
47
|
}
|
|
@@ -117,11 +120,10 @@ export class GithubRepository extends Repository {
|
|
|
117
120
|
* API endpoint for ourselfs.
|
|
118
121
|
* @return {string}
|
|
119
122
|
*/
|
|
120
|
-
get api()
|
|
121
|
-
|
|
122
|
-
return `repos/${this.slug}`;
|
|
123
|
+
get api() {
|
|
124
|
+
return `repos/${this.slug}`;
|
|
123
125
|
}
|
|
124
|
-
|
|
126
|
+
|
|
125
127
|
/**
|
|
126
128
|
* {@link https://developer.github.com/v3/repos/#update-a-repository}
|
|
127
129
|
*/
|
|
@@ -137,7 +139,6 @@ export class GithubRepository extends Repository {
|
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
141
|
|
|
140
|
-
|
|
141
142
|
#ref;
|
|
142
143
|
|
|
143
144
|
/**
|
|
@@ -177,7 +178,7 @@ export class GithubRepository extends Repository {
|
|
|
177
178
|
|
|
178
179
|
async createBranch(name, from, options) {
|
|
179
180
|
await this.initializeBranches();
|
|
180
|
-
|
|
181
|
+
|
|
181
182
|
const branch = await this.branch(name);
|
|
182
183
|
if (branch) {
|
|
183
184
|
return branch;
|
|
@@ -189,8 +190,7 @@ export class GithubRepository extends Repository {
|
|
|
189
190
|
sha = await this.refId(
|
|
190
191
|
`heads/${from ? from.name : this.defaultBranchName}`
|
|
191
192
|
);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
193
|
+
} else {
|
|
194
194
|
/*
|
|
195
195
|
* https://stackoverflow.com/questions/9765453/is-gits-semi-secret-empty-tree-object-reliable-and-why-is-there-not-a-symbolic/9766506#9766506
|
|
196
196
|
* sha1:4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
@@ -262,7 +262,7 @@ export class GithubRepository extends Repository {
|
|
|
262
262
|
const { response, json } = await this.provider.fetchJSON(next);
|
|
263
263
|
|
|
264
264
|
for (const h of json) {
|
|
265
|
-
|
|
265
|
+
this.addHook(h.name, {
|
|
266
266
|
...h,
|
|
267
267
|
...h.config
|
|
268
268
|
});
|