github-repository-provider 7.26.22 → 7.26.25
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 +5 -5
- package/src/github-provider.mjs +11 -6
- package/src/github-repository.mjs +19 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.26.
|
|
3
|
+
"version": "7.26.25",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"content-entry": "^5.0.0",
|
|
34
34
|
"fetch-link-util": "^1.0.8",
|
|
35
|
-
"fetch-rate-limit-util": "^2.
|
|
35
|
+
"fetch-rate-limit-util": "^2.10.0",
|
|
36
36
|
"matching-iterator": "^2.0.4",
|
|
37
|
-
"node-fetch": "^3.2.
|
|
37
|
+
"node-fetch": "^3.2.4",
|
|
38
38
|
"one-time-execution-method": "^2.0.13",
|
|
39
|
-
"repository-provider": "^28.3.
|
|
39
|
+
"repository-provider": "^28.3.6"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"ava": "^4.2.0",
|
|
43
43
|
"c8": "^7.11.2",
|
|
44
44
|
"documentation": "^13.2.5",
|
|
45
|
-
"repository-provider-test-support": "^2.1.
|
|
45
|
+
"repository-provider-test-support": "^2.1.8",
|
|
46
46
|
"semantic-release": "^19.0.2"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
package/src/github-provider.mjs
CHANGED
|
@@ -92,7 +92,7 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
fetch(url, options = {}, responseHandler) {
|
|
95
|
+
fetch(url, options = {}, responseHandler, actions) {
|
|
96
96
|
return stateActionHandler(
|
|
97
97
|
fetch,
|
|
98
98
|
new URL(url, this.api),
|
|
@@ -104,15 +104,20 @@ export class GithubProvider extends MultiGroupProvider {
|
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
responseHandler,
|
|
107
|
-
|
|
107
|
+
actions,
|
|
108
108
|
(url, ...args) => this.trace(url.toString(), ...args)
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
fetchJSON(url, options) {
|
|
113
|
-
return this.fetch(
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
fetchJSON(url, options, actions) {
|
|
113
|
+
return this.fetch(
|
|
114
|
+
url,
|
|
115
|
+
options,
|
|
116
|
+
async response => {
|
|
117
|
+
return { response, json: await response.json() };
|
|
118
|
+
},
|
|
119
|
+
actions
|
|
120
|
+
);
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
/**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { replaceWithOneTimeExecutionMethod } from "one-time-execution-method";
|
|
2
2
|
import { Repository } from "repository-provider";
|
|
3
3
|
import { getHeaderLink } from "fetch-link-util";
|
|
4
|
+
import { defaultStateActions, errorHandler } from "fetch-rate-limit-util";
|
|
5
|
+
|
|
6
|
+
const confictErrorActions = {
|
|
7
|
+
...defaultStateActions,
|
|
8
|
+
409: errorHandler
|
|
9
|
+
};
|
|
4
10
|
|
|
5
11
|
/**
|
|
6
12
|
* Repository on GitHub.
|
|
@@ -39,7 +45,7 @@ export class GithubRepository extends Repository {
|
|
|
39
45
|
|
|
40
46
|
/**
|
|
41
47
|
* {@link https://docs.github.com/en/rest/reference/commits#list-commits}
|
|
42
|
-
* @param {Object} options
|
|
48
|
+
* @param {Object} options
|
|
43
49
|
* @returns {AsyncIterator<Commit>}
|
|
44
50
|
*/
|
|
45
51
|
async *commits(options) {
|
|
@@ -48,12 +54,12 @@ export class GithubRepository extends Repository {
|
|
|
48
54
|
do {
|
|
49
55
|
const { response, json } = await this.provider.fetchJSON(next);
|
|
50
56
|
|
|
51
|
-
for(const c of json) {
|
|
57
|
+
for (const c of json) {
|
|
52
58
|
yield {
|
|
53
59
|
sha: c.sha,
|
|
54
60
|
message: c.message,
|
|
55
61
|
author: c.author,
|
|
56
|
-
committer: c.committer
|
|
62
|
+
committer: c.committer
|
|
57
63
|
};
|
|
58
64
|
}
|
|
59
65
|
next = getHeaderLink(response.headers);
|
|
@@ -140,9 +146,10 @@ export class GithubRepository extends Repository {
|
|
|
140
146
|
this._ref = new Map();
|
|
141
147
|
}
|
|
142
148
|
|
|
143
|
-
// TODO: 409 -> none repeatable
|
|
144
149
|
const { response, json } = await this.provider.fetchJSON(
|
|
145
|
-
`repos/${this.slug}/git/ref/${ref}
|
|
150
|
+
`repos/${this.slug}/git/ref/${ref}`,
|
|
151
|
+
undefined,
|
|
152
|
+
confictErrorActions
|
|
146
153
|
);
|
|
147
154
|
|
|
148
155
|
// TODO why does this happen ?
|
|
@@ -158,6 +165,8 @@ export class GithubRepository extends Repository {
|
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
async createBranch(name, from, options) {
|
|
168
|
+
await this.initializeBranches();
|
|
169
|
+
|
|
161
170
|
const branch = this._branches.get(name);
|
|
162
171
|
if (branch) {
|
|
163
172
|
return branch;
|
|
@@ -182,7 +191,9 @@ export class GithubRepository extends Repository {
|
|
|
182
191
|
console.log(res);
|
|
183
192
|
*/
|
|
184
193
|
} else {
|
|
185
|
-
sha = await this.refId(
|
|
194
|
+
sha = await this.refId(
|
|
195
|
+
`heads/${from ? from.name : this.defaultBranchName}`
|
|
196
|
+
);
|
|
186
197
|
}
|
|
187
198
|
|
|
188
199
|
const res = await this.provider.fetch(`repos/${this.slug}/git/refs`, {
|
|
@@ -196,6 +207,8 @@ export class GithubRepository extends Repository {
|
|
|
196
207
|
if (res.ok) {
|
|
197
208
|
return this.addBranch(name, options);
|
|
198
209
|
}
|
|
210
|
+
|
|
211
|
+
throw new Error(`Unable to create branch '${name}'`);
|
|
199
212
|
}
|
|
200
213
|
|
|
201
214
|
async deleteBranch(name) {
|