github-repository-provider 7.24.3 → 7.24.7
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/README.md +1 -1
- package/package.json +4 -4
- package/src/github-branch.mjs +8 -20
- package/src/github-provider.mjs +8 -4
- package/src/github-pull-request.mjs +2 -8
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ Writes content into the branch
|
|
|
97
97
|
|
|
98
98
|
* `entry` **ConentEntry**
|
|
99
99
|
|
|
100
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<
|
|
100
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<ConentEntry>** written content with sha values set
|
|
101
101
|
|
|
102
102
|
### baseTreeSha
|
|
103
103
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.24.
|
|
3
|
+
"version": "7.24.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"matching-iterator": "^2.0.0",
|
|
37
37
|
"node-fetch": "3.1.0",
|
|
38
38
|
"one-time-execution-method": "^2.0.9",
|
|
39
|
-
"repository-provider": "^26.0.
|
|
39
|
+
"repository-provider": "^26.0.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"ava": "^3.15.0",
|
|
43
|
-
"c8": "^7.
|
|
43
|
+
"c8": "^7.11.0",
|
|
44
44
|
"documentation": "^13.2.5",
|
|
45
|
-
"repository-provider-test-support": "^1.8.
|
|
45
|
+
"repository-provider-test-support": "^1.8.15",
|
|
46
46
|
"semantic-release": "^18.0.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
package/src/github-branch.mjs
CHANGED
|
@@ -15,17 +15,16 @@ export class GithubBranch extends Branch {
|
|
|
15
15
|
* Writes content into the branch
|
|
16
16
|
* {@link https://developer.github.com/v3/git/blobs/#get-a-blob}
|
|
17
17
|
* @param {ConentEntry} entry
|
|
18
|
-
* @return {Promise<
|
|
18
|
+
* @return {Promise<ConentEntry>} written content with sha values set
|
|
19
19
|
*/
|
|
20
20
|
async writeEntry(entry) {
|
|
21
|
-
const
|
|
21
|
+
const json = await this.provider.fetchJSON(`repos/${this.slug}/git/blobs`, {
|
|
22
22
|
method: "POST",
|
|
23
23
|
body: JSON.stringify({
|
|
24
24
|
content: await entry.string,
|
|
25
25
|
encoding: "utf8"
|
|
26
26
|
})
|
|
27
27
|
});
|
|
28
|
-
const json = await res.json();
|
|
29
28
|
|
|
30
29
|
entry.sha = json.sha;
|
|
31
30
|
|
|
@@ -37,15 +36,10 @@ export class GithubBranch extends Branch {
|
|
|
37
36
|
* @param {string} sha
|
|
38
37
|
*/
|
|
39
38
|
async baseTreeSha(sha) {
|
|
40
|
-
const
|
|
39
|
+
const json = await this.provider.fetchJSON(
|
|
41
40
|
`repos/${this.slug}/git/commits/${sha}`
|
|
42
41
|
);
|
|
43
|
-
|
|
44
|
-
const json = await res.json();
|
|
45
|
-
return json.tree.sha;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
throw new Error(`Unable to decode ${res.url}`);
|
|
42
|
+
return json.tree.sha;
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
/**
|
|
@@ -117,16 +111,11 @@ export class GithubBranch extends Branch {
|
|
|
117
111
|
* @param {string} name
|
|
118
112
|
*/
|
|
119
113
|
async entry(name) {
|
|
120
|
-
const
|
|
114
|
+
const json = await this.provider.fetchJSON(
|
|
121
115
|
`repos/${this.slug}/contents/${name}?ref=${this.ref}`
|
|
122
116
|
);
|
|
123
117
|
|
|
124
|
-
|
|
125
|
-
const json = await res.json();
|
|
126
|
-
return new this.entryClass(name, Buffer.from(json.content, "base64"));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
throw new Error(res.status);
|
|
118
|
+
return new this.entryClass(name, Buffer.from(json.content, "base64"));
|
|
130
119
|
}
|
|
131
120
|
|
|
132
121
|
/** @inheritdoc */
|
|
@@ -159,7 +148,7 @@ export class GithubBranch extends Branch {
|
|
|
159
148
|
} catch (e) {
|
|
160
149
|
// errno: 'ERR_STREAM_PREMATURE_CLOSE',
|
|
161
150
|
// code: 'ERR_STREAM_PREMATURE_CLOSE',
|
|
162
|
-
|
|
151
|
+
|
|
163
152
|
this.error(e);
|
|
164
153
|
}
|
|
165
154
|
}
|
|
@@ -215,11 +204,10 @@ class LazyBufferContentEntry extends BufferContentEntryMixin(ContentEntry) {
|
|
|
215
204
|
}
|
|
216
205
|
|
|
217
206
|
const branch = this.branch;
|
|
218
|
-
const
|
|
207
|
+
const json = await branch.provider.fetchJSON(
|
|
219
208
|
`repos/${branch.slug}/contents/${this.name}?ref=${branch.ref}`
|
|
220
209
|
);
|
|
221
210
|
|
|
222
|
-
const json = await res.json();
|
|
223
211
|
this._buffer = Buffer.from(json.content, "base64");
|
|
224
212
|
return this._buffer;
|
|
225
213
|
}
|
package/src/github-provider.mjs
CHANGED
|
@@ -117,17 +117,21 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
async fetchJSON(url, options) {
|
|
120
|
-
|
|
120
|
+
let i = 1;
|
|
121
|
+
while (true) {
|
|
121
122
|
try {
|
|
122
123
|
const response = await this.fetch(url, options);
|
|
123
124
|
if (!response.ok) {
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
throw new Error(
|
|
126
|
+
`Unable to fetch ${response.url} (${response.status}) try #${i}`
|
|
127
|
+
);
|
|
126
128
|
}
|
|
127
129
|
return await response.json();
|
|
128
130
|
} catch (e) {
|
|
131
|
+
if (i++ >= 3) {
|
|
132
|
+
throw e;
|
|
133
|
+
}
|
|
129
134
|
this.error(e);
|
|
130
|
-
throw e;
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
}
|
|
@@ -72,7 +72,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
72
72
|
return p;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const
|
|
75
|
+
const json = await destination.provider.fetchJSON(
|
|
76
76
|
`repos/${destination.repository.slug}/pulls`,
|
|
77
77
|
{
|
|
78
78
|
method: "POST",
|
|
@@ -84,13 +84,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
84
84
|
}
|
|
85
85
|
);
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (res.ok) {
|
|
90
|
-
return new this(source, destination, json.number, json);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
throw new Error(json.errors.map(e => e.message).join(";"));
|
|
87
|
+
return new this(source, destination, json.number, json);
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
/**
|