@lonca/baron-adapter-github 0.4.0 → 0.6.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/dist/index.js +29 -11
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -119,6 +119,18 @@ function createGithubTransport(options) {
|
|
|
119
119
|
"NOT_SUPPORTED"
|
|
120
120
|
);
|
|
121
121
|
},
|
|
122
|
+
async listIterations() {
|
|
123
|
+
throw new BaronError(
|
|
124
|
+
"GitHub issues have no native iterations/sprints; handled by the gap policy, not the transport.",
|
|
125
|
+
"NOT_SUPPORTED"
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
async setIteration() {
|
|
129
|
+
throw new BaronError(
|
|
130
|
+
"GitHub issues have no native iterations/sprints; handled by the gap policy, not the transport.",
|
|
131
|
+
"NOT_SUPPORTED"
|
|
132
|
+
);
|
|
133
|
+
},
|
|
122
134
|
async queryIssues(query) {
|
|
123
135
|
const stateValue = query.target?.[TARGET.STATE];
|
|
124
136
|
const label = query.target?.[TARGET.LABEL];
|
|
@@ -228,24 +240,30 @@ function createGithubScmTransport(options) {
|
|
|
228
240
|
});
|
|
229
241
|
return { id: String(data.id), url: data.html_url };
|
|
230
242
|
},
|
|
231
|
-
async findPullRequestByBranch(sourceBranch) {
|
|
243
|
+
async findPullRequestByBranch(sourceBranch, stateFilter) {
|
|
244
|
+
const listState = stateFilter === "open" ? "open" : stateFilter === "all" ? "all" : "closed";
|
|
232
245
|
const { data } = await octokit.rest.pulls.list({
|
|
233
246
|
owner,
|
|
234
247
|
repo,
|
|
235
|
-
state:
|
|
248
|
+
state: listState,
|
|
236
249
|
head: `${owner}:${sourceBranch}`,
|
|
237
|
-
|
|
250
|
+
sort: "created",
|
|
251
|
+
direction: "desc",
|
|
252
|
+
per_page: stateFilter === "open" || stateFilter === "all" ? 1 : 20
|
|
238
253
|
});
|
|
239
|
-
const
|
|
240
|
-
|
|
254
|
+
const isMerged = (pr) => pr.merged_at != null;
|
|
255
|
+
const prState = (pr) => isMerged(pr) ? "merged" : pr.state === "closed" ? "closed" : "open";
|
|
256
|
+
const match = stateFilter === "merged" ? data.find(isMerged) : stateFilter === "closed" ? data.find((pr) => pr.state === "closed" && !isMerged(pr)) : data[0];
|
|
257
|
+
if (match === void 0) return void 0;
|
|
241
258
|
return {
|
|
242
|
-
id: String(
|
|
243
|
-
number: String(
|
|
244
|
-
title:
|
|
245
|
-
url:
|
|
259
|
+
id: String(match.number),
|
|
260
|
+
number: String(match.number),
|
|
261
|
+
title: match.title,
|
|
262
|
+
url: match.html_url,
|
|
246
263
|
sourceBranch,
|
|
247
|
-
targetBranch:
|
|
248
|
-
draft:
|
|
264
|
+
targetBranch: match.base.ref,
|
|
265
|
+
draft: match.draft ?? false,
|
|
266
|
+
state: prState(match)
|
|
249
267
|
};
|
|
250
268
|
},
|
|
251
269
|
async defaultBranch() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lonca/baron-adapter-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"octokit": "^5.0.5",
|
|
19
|
-
"@lonca/baron-core": "0.
|
|
19
|
+
"@lonca/baron-core": "0.6.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/node": "^22.0.0",
|
|
23
|
-
"@lonca/baron-conformance": "0.
|
|
23
|
+
"@lonca/baron-conformance": "0.6.0"
|
|
24
24
|
},
|
|
25
25
|
"description": "Baron adapter for GitHub: issues, scm, ci, deploy.",
|
|
26
26
|
"keywords": [
|