github-repository-provider 7.24.4 → 7.24.8
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 +9 -37
- 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.8",
|
|
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.
|
|
45
|
+
"repository-provider-test-support": "^1.9.0",
|
|
46
46
|
"semantic-release": "^18.0.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
package/src/github-branch.mjs
CHANGED
|
@@ -36,15 +36,10 @@ export class GithubBranch extends Branch {
|
|
|
36
36
|
* @param {string} sha
|
|
37
37
|
*/
|
|
38
38
|
async baseTreeSha(sha) {
|
|
39
|
-
const
|
|
39
|
+
const json = await this.provider.fetchJSON(
|
|
40
40
|
`repos/${this.slug}/git/commits/${sha}`
|
|
41
41
|
);
|
|
42
|
-
|
|
43
|
-
const json = await res.json();
|
|
44
|
-
return json.tree.sha;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
throw new Error(`Unable to decode ${res.url}`);
|
|
42
|
+
return json.tree.sha;
|
|
48
43
|
}
|
|
49
44
|
|
|
50
45
|
/**
|
|
@@ -116,16 +111,11 @@ export class GithubBranch extends Branch {
|
|
|
116
111
|
* @param {string} name
|
|
117
112
|
*/
|
|
118
113
|
async entry(name) {
|
|
119
|
-
const
|
|
114
|
+
const json = await this.provider.fetchJSON(
|
|
120
115
|
`repos/${this.slug}/contents/${name}?ref=${this.ref}`
|
|
121
116
|
);
|
|
122
117
|
|
|
123
|
-
|
|
124
|
-
const json = await res.json();
|
|
125
|
-
return new this.entryClass(name, Buffer.from(json.content, "base64"));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
throw new Error(res.status);
|
|
118
|
+
return new this.entryClass(name, Buffer.from(json.content, "base64"));
|
|
129
119
|
}
|
|
130
120
|
|
|
131
121
|
/** @inheritdoc */
|
|
@@ -145,27 +135,10 @@ export class GithubBranch extends Branch {
|
|
|
145
135
|
* @return {Object[]}
|
|
146
136
|
*/
|
|
147
137
|
async tree(treeSha) {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
res = await this.provider.fetch(url);
|
|
154
|
-
if (res.ok) {
|
|
155
|
-
const json = await res.json();
|
|
156
|
-
return json.tree;
|
|
157
|
-
}
|
|
158
|
-
} catch (e) {
|
|
159
|
-
// errno: 'ERR_STREAM_PREMATURE_CLOSE',
|
|
160
|
-
// code: 'ERR_STREAM_PREMATURE_CLOSE',
|
|
161
|
-
|
|
162
|
-
this.error(e);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
console.log(res.errno, res.code);
|
|
167
|
-
|
|
168
|
-
throw new Error(res.status);
|
|
138
|
+
const json = await this.provider.fetchJSON(
|
|
139
|
+
`repos/${this.slug}/git/trees/${treeSha}?recursive=1`
|
|
140
|
+
);
|
|
141
|
+
return json.tree;
|
|
169
142
|
}
|
|
170
143
|
|
|
171
144
|
async *entries(patterns) {
|
|
@@ -214,11 +187,10 @@ class LazyBufferContentEntry extends BufferContentEntryMixin(ContentEntry) {
|
|
|
214
187
|
}
|
|
215
188
|
|
|
216
189
|
const branch = this.branch;
|
|
217
|
-
const
|
|
190
|
+
const json = await branch.provider.fetchJSON(
|
|
218
191
|
`repos/${branch.slug}/contents/${this.name}?ref=${branch.ref}`
|
|
219
192
|
);
|
|
220
193
|
|
|
221
|
-
const json = await res.json();
|
|
222
194
|
this._buffer = Buffer.from(json.content, "base64");
|
|
223
195
|
return this._buffer;
|
|
224
196
|
}
|
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
|
/**
|