github-repository-provider 7.26.41 → 7.27.0
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 +1 -1
- package/src/github-pull-request.mjs +4 -4
- package/src/github-repository.mjs +20 -11
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
39
39
|
for (const state of [
|
|
40
40
|
...(filter.states ? filter.states : this.defaultListStates)
|
|
41
41
|
]) {
|
|
42
|
-
let next =
|
|
42
|
+
let next = `${repository.api}/pulls?state=${state}${head}${base}`;
|
|
43
43
|
|
|
44
44
|
do {
|
|
45
45
|
const provider = repository.provider;
|
|
@@ -73,7 +73,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const { json } = await destination.provider.fetchJSON(
|
|
76
|
-
|
|
76
|
+
`${destination.repository.api}/pulls`,
|
|
77
77
|
{
|
|
78
78
|
method: "POST",
|
|
79
79
|
body: JSON.stringify({
|
|
@@ -92,7 +92,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
92
92
|
*/
|
|
93
93
|
async _merge(method = "MERGE") {
|
|
94
94
|
const res = await this.provider.fetch(
|
|
95
|
-
|
|
95
|
+
`${this.source.repository.api}/pulls/${this.number}/merge`,
|
|
96
96
|
{
|
|
97
97
|
method: "PUT",
|
|
98
98
|
body: JSON.stringify({ merge_method: method, sha: "???" })
|
|
@@ -105,7 +105,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
105
105
|
*/
|
|
106
106
|
async update() {
|
|
107
107
|
const res = await this.provider.fetch(
|
|
108
|
-
|
|
108
|
+
`${this.source.repository.api}/pulls/${this.number}`,
|
|
109
109
|
{
|
|
110
110
|
method: "PATCH",
|
|
111
111
|
body: JSON.stringify({
|
|
@@ -49,7 +49,7 @@ export class GithubRepository extends Repository {
|
|
|
49
49
|
* @returns {AsyncIterator<Commit>}
|
|
50
50
|
*/
|
|
51
51
|
async *commits(options) {
|
|
52
|
-
let next =
|
|
52
|
+
let next = `${this.api}/commits`;
|
|
53
53
|
|
|
54
54
|
do {
|
|
55
55
|
const { response, json } = await this.provider.fetchJSON(next);
|
|
@@ -66,8 +66,8 @@ export class GithubRepository extends Repository {
|
|
|
66
66
|
} while (next);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
async
|
|
70
|
-
let next =
|
|
69
|
+
async #initializeSlot(typeName, addMethodName) {
|
|
70
|
+
let next = `${this.api}/${typeName}`;
|
|
71
71
|
|
|
72
72
|
do {
|
|
73
73
|
const { response, json } = await this.provider.fetchJSON(next);
|
|
@@ -80,14 +80,14 @@ export class GithubRepository extends Repository {
|
|
|
80
80
|
* {@link https://developer.github.com/v3/repos/branches/#list-branches}
|
|
81
81
|
*/
|
|
82
82
|
async initializeBranches() {
|
|
83
|
-
return this
|
|
83
|
+
return this.#initializeSlot("branches", "addBranch");
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* {@link https://docs.github.com/en/rest/reference/repos#list-repository-tags}
|
|
88
88
|
*/
|
|
89
89
|
async initializeTags() {
|
|
90
|
-
return this
|
|
90
|
+
return this.#initializeSlot("tags", "addTag");
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -113,11 +113,20 @@ export class GithubRepository extends Repository {
|
|
|
113
113
|
return `${this.provider.url}${this.fullName}#readme`;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* API endpoint for ourselfs.
|
|
118
|
+
* @return {string}
|
|
119
|
+
*/
|
|
120
|
+
get api()
|
|
121
|
+
{
|
|
122
|
+
return `repos/${this.slug}`;
|
|
123
|
+
}
|
|
124
|
+
|
|
116
125
|
/**
|
|
117
126
|
* {@link https://developer.github.com/v3/repos/#update-a-repository}
|
|
118
127
|
*/
|
|
119
128
|
async update() {
|
|
120
|
-
return this.provider.fetch(
|
|
129
|
+
return this.provider.fetch(this.api, {
|
|
121
130
|
method: "PATCH",
|
|
122
131
|
body: JSON.stringify(
|
|
123
132
|
mapAttributesInverse(
|
|
@@ -150,7 +159,7 @@ export class GithubRepository extends Repository {
|
|
|
150
159
|
}
|
|
151
160
|
|
|
152
161
|
const { response, json } = await this.provider.fetchJSON(
|
|
153
|
-
|
|
162
|
+
`${this.api}/git/ref/${ref}`,
|
|
154
163
|
undefined,
|
|
155
164
|
conflictErrorActions
|
|
156
165
|
);
|
|
@@ -199,7 +208,7 @@ export class GithubRepository extends Repository {
|
|
|
199
208
|
*/
|
|
200
209
|
}
|
|
201
210
|
|
|
202
|
-
const res = await this.provider.fetch(
|
|
211
|
+
const res = await this.provider.fetch(`${this.api}/git/refs`, {
|
|
203
212
|
method: "POST",
|
|
204
213
|
body: JSON.stringify({
|
|
205
214
|
ref: `refs/heads/${name}`,
|
|
@@ -216,7 +225,7 @@ export class GithubRepository extends Repository {
|
|
|
216
225
|
|
|
217
226
|
async deleteBranch(name) {
|
|
218
227
|
const res = await this.provider.fetch(
|
|
219
|
-
|
|
228
|
+
`${this.api}/git/refs/heads/${name}`,
|
|
220
229
|
{
|
|
221
230
|
method: "DELETE"
|
|
222
231
|
}
|
|
@@ -233,7 +242,7 @@ export class GithubRepository extends Repository {
|
|
|
233
242
|
* @param {string} name
|
|
234
243
|
*/
|
|
235
244
|
async deletePullRequest(name) {
|
|
236
|
-
const res = await this.provider.fetch(
|
|
245
|
+
const res = await this.provider.fetch(`${this.api}/pulls/${name}`, {
|
|
237
246
|
method: "PATCH",
|
|
238
247
|
body: JSON.stringify({ state: "closed" })
|
|
239
248
|
});
|
|
@@ -247,7 +256,7 @@ export class GithubRepository extends Repository {
|
|
|
247
256
|
* {@link https://developer.github.com/v3/repos/hooks/}
|
|
248
257
|
*/
|
|
249
258
|
async initializeHooks() {
|
|
250
|
-
let next =
|
|
259
|
+
let next = `${this.api}/hooks`;
|
|
251
260
|
|
|
252
261
|
do {
|
|
253
262
|
const { response, json } = await this.provider.fetchJSON(next);
|