github-repository-provider 7.33.37 → 7.33.39
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 +2 -2
- package/src/github-pull-request.mjs +32 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.33.
|
|
3
|
+
"version": "7.33.39",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"etag-cache-leveldb": "^1.4.1",
|
|
46
46
|
"leveldown": "^6.1.1",
|
|
47
47
|
"levelup": "^5.1.1",
|
|
48
|
-
"repository-provider-test-support": "^2.2.
|
|
48
|
+
"repository-provider-test-support": "^2.2.35",
|
|
49
49
|
"semantic-release": "^20.0.2"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
@@ -16,7 +16,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
16
16
|
static get attributeMapping() {
|
|
17
17
|
return {
|
|
18
18
|
...super.attributeMapping,
|
|
19
|
-
url: "api"
|
|
19
|
+
url: "api" // TODO undefined ?
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -33,22 +33,25 @@ export class GithubPullRequest extends PullRequest {
|
|
|
33
33
|
* @param {Object} filter
|
|
34
34
|
*/
|
|
35
35
|
static async *list(repository, filter = {}) {
|
|
36
|
-
const
|
|
37
|
-
branch === undefined
|
|
38
|
-
? ""
|
|
39
|
-
: `&${name}=${branch.owner.name}:${branch.name}`;
|
|
36
|
+
const query = {};
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
if (filter.source) {
|
|
39
|
+
query.head = `${filter.source.owner.owner.name}:${filter.source.name}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (filter.destination) {
|
|
43
|
+
query.base = filter.destination.name;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for (const state of filter.states || this.defaultListStates) {
|
|
47
|
+
query.state = state;
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
...(filter.states ? filter.states : this.defaultListStates)
|
|
46
|
-
]) {
|
|
47
|
-
let next = `${repository.api}/pulls?state=${state}${head}${base}`;
|
|
49
|
+
let next = `${repository.api}/pulls?${new URLSearchParams(query)}`;
|
|
48
50
|
|
|
49
51
|
do {
|
|
50
52
|
const provider = repository.provider;
|
|
51
53
|
const { response, json } = await provider.fetchJSON(next);
|
|
54
|
+
|
|
52
55
|
for (const node of json) {
|
|
53
56
|
const [source, dest] = await Promise.all(
|
|
54
57
|
[node.head, node.base].map(r =>
|
|
@@ -76,7 +79,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
76
79
|
})) {
|
|
77
80
|
return p;
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
|
|
80
83
|
const { response, json } = await destination.provider.fetchJSON(
|
|
81
84
|
`${destination.repository.api}/pulls`,
|
|
82
85
|
{
|
|
@@ -90,40 +93,38 @@ export class GithubPullRequest extends PullRequest {
|
|
|
90
93
|
);
|
|
91
94
|
|
|
92
95
|
if (!response.ok) {
|
|
93
|
-
throw new Error(response.statusText +
|
|
96
|
+
throw new Error(response.statusText + " (" + response.status + ")");
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
return new this(source, destination, json.number, json);
|
|
97
100
|
}
|
|
98
101
|
|
|
102
|
+
get api() {
|
|
103
|
+
return `${this.destination.repository.api}/pulls/${this.number}`;
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
/**
|
|
100
107
|
* {@link https://developer.github.com/v3/pulls/#merge-a-pull-request}
|
|
101
108
|
*/
|
|
102
109
|
async _merge(method = "MERGE") {
|
|
103
|
-
const res = await this.provider.fetch(
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
body: JSON.stringify({ merge_method: method, sha: "???" })
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
+
const res = await this.provider.fetch(`${this.api}/merge`, {
|
|
111
|
+
method: "PUT",
|
|
112
|
+
body: JSON.stringify({ merge_method: method, sha: "???" })
|
|
113
|
+
});
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/**
|
|
113
117
|
*
|
|
114
118
|
*/
|
|
115
119
|
async update() {
|
|
116
|
-
const res = await this.provider.fetch(
|
|
117
|
-
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
body:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
);
|
|
120
|
+
const res = await this.provider.fetch(this.api, {
|
|
121
|
+
method: "PATCH",
|
|
122
|
+
body: JSON.stringify({
|
|
123
|
+
title: this.title,
|
|
124
|
+
body: this.body,
|
|
125
|
+
state: this.state
|
|
126
|
+
})
|
|
127
|
+
});
|
|
127
128
|
console.log(res);
|
|
128
129
|
}
|
|
129
130
|
}
|