github-repository-provider 7.26.21 → 7.26.24

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-repository-provider",
3
- "version": "7.26.21",
3
+ "version": "7.26.24",
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.9.5",
35
+ "fetch-rate-limit-util": "^2.10.0",
36
36
  "matching-iterator": "^2.0.4",
37
- "node-fetch": "^3.2.3",
37
+ "node-fetch": "^3.2.4",
38
38
  "one-time-execution-method": "^2.0.13",
39
- "repository-provider": "^28.3.0"
39
+ "repository-provider": "^28.3.5"
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.5",
45
+ "repository-provider-test-support": "^2.1.8",
46
46
  "semantic-release": "^19.0.2"
47
47
  },
48
48
  "engines": {
@@ -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
- undefined,
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(url, options, async response => {
114
- return { response, json: await response.json() };
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);
@@ -141,7 +147,9 @@ export class GithubRepository extends Repository {
141
147
  }
142
148
 
143
149
  const { response, json } = await this.provider.fetchJSON(
144
- `repos/${this.slug}/git/ref/${ref}`
150
+ `repos/${this.slug}/git/ref/${ref}`,
151
+ undefined,
152
+ confictErrorActions
145
153
  );
146
154
 
147
155
  // TODO why does this happen ?
@@ -157,6 +165,8 @@ export class GithubRepository extends Repository {
157
165
  }
158
166
 
159
167
  async createBranch(name, from, options) {
168
+ await this.initializeBranches();
169
+
160
170
  const branch = this._branches.get(name);
161
171
  if (branch) {
162
172
  return branch;
@@ -181,7 +191,9 @@ export class GithubRepository extends Repository {
181
191
  console.log(res);
182
192
  */
183
193
  } else {
184
- sha = await this.refId(`heads/${from ? from.name : this.defaultBranchName}` );
194
+ sha = await this.refId(
195
+ `heads/${from ? from.name : this.defaultBranchName}`
196
+ );
185
197
  }
186
198
 
187
199
  const res = await this.provider.fetch(`repos/${this.slug}/git/refs`, {
@@ -195,6 +207,8 @@ export class GithubRepository extends Repository {
195
207
  if (res.ok) {
196
208
  return this.addBranch(name, options);
197
209
  }
210
+
211
+ throw new Error(`Unable to create branch '${name}'`);
198
212
  }
199
213
 
200
214
  async deleteBranch(name) {
@@ -236,9 +250,7 @@ export class GithubRepository extends Repository {
236
250
  const { response, json } = await this.provider.fetchJSON(next);
237
251
 
238
252
  for (const h of json) {
239
- const id = h.id;
240
- delete h.id;
241
- new this.hookClass(this, id, new Set(h.events), {
253
+ new this.hookClass(this, h.name, new Set(h.events), {
242
254
  ...h,
243
255
  ...h.config
244
256
  });