next-issue 0.17.0 → 0.17.1
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/README.md +4 -1
- package/dist/github.mjs +23 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,7 +97,10 @@ when:
|
|
|
97
97
|
because branch protection asks for a human approval;
|
|
98
98
|
- an agent does not finish in `agentTimeoutMinutes`;
|
|
99
99
|
- the setup command fails, or does not finish in `setupTimeoutMinutes`;
|
|
100
|
-
- a step of the run fails with an error.
|
|
100
|
+
- a step of the run fails with an error. A `gh` call that is safe to repeat,
|
|
101
|
+
such as a read or a label edit, is tried up to three times first when the
|
|
102
|
+
network fails. A `gh pr create` or `gh pr comment` is tried once, so a lost
|
|
103
|
+
reply never makes a duplicate.
|
|
101
104
|
|
|
102
105
|
The fixer sees the findings of all earlier rounds, not only the last one, with
|
|
103
106
|
its own disputes next to them. From round two, the reviewer judges only the
|
package/dist/github.mjs
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
import { must, run } from "./exec.mjs";
|
|
2
2
|
const CHECK_PENDING_CODE = 8;
|
|
3
3
|
const READ_TRIES = 3;
|
|
4
|
+
const NETWORK_TRIES = 3;
|
|
5
|
+
const NETWORK_FAULT = /unexpected EOF|connection reset|connection refused|i\/o timeout|TLS handshake timeout|HTTP 50[234]/i;
|
|
4
6
|
const KNOWN_LABELS = new Map();
|
|
5
7
|
const NO_CHECKS = /no checks reported/i;
|
|
6
8
|
function slug(repo) {
|
|
7
9
|
return `${repo.owner}/${repo.name}`;
|
|
8
10
|
}
|
|
9
|
-
async function
|
|
11
|
+
async function repeatable(args, options) {
|
|
12
|
+
for (let attempt = 1;; attempt += 1) {
|
|
13
|
+
try {
|
|
14
|
+
return await must("gh", args, options);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (attempt >= NETWORK_TRIES || !(error instanceof Error) || !NETWORK_FAULT.test(error.message)) {
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
await new Promise((resolve) => setTimeout(resolve, attempt * 1000));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function gh(repo, args) {
|
|
25
|
+
return repeatable([...args, "--repo", slug(repo)], { cwd: repo.root });
|
|
26
|
+
}
|
|
27
|
+
async function ghOnce(repo, args, input) {
|
|
10
28
|
return must("gh", [...args, "--repo", slug(repo)], { cwd: repo.root, input });
|
|
11
29
|
}
|
|
12
30
|
export async function defaultBranch(repo) {
|
|
13
|
-
const raw = await
|
|
31
|
+
const raw = await repeatable(["repo", "view", slug(repo), "--json", "defaultBranchRef"], {
|
|
14
32
|
cwd: repo.root,
|
|
15
33
|
});
|
|
16
34
|
return JSON.parse(raw).defaultBranchRef.name;
|
|
@@ -45,7 +63,7 @@ export async function issueComments(repo, issue) {
|
|
|
45
63
|
return parsed.comments.map((comment) => `@${comment.author.login}: ${comment.body}`);
|
|
46
64
|
}
|
|
47
65
|
export async function openBlockers(repo, issue) {
|
|
48
|
-
const raw = await
|
|
66
|
+
const raw = await repeatable([
|
|
49
67
|
"api",
|
|
50
68
|
"--paginate",
|
|
51
69
|
`repos/${slug(repo)}/issues/${issue}/dependencies/blocked_by`,
|
|
@@ -100,7 +118,7 @@ export async function findPr(repo, branch) {
|
|
|
100
118
|
return parsed[0]?.number;
|
|
101
119
|
}
|
|
102
120
|
export async function createPr(repo, branch, base, title, body, draft) {
|
|
103
|
-
const created = await
|
|
121
|
+
const created = await ghOnce(repo, [
|
|
104
122
|
"pr",
|
|
105
123
|
"create",
|
|
106
124
|
"--head",
|
|
@@ -245,5 +263,5 @@ export async function mergePr(repo, pr) {
|
|
|
245
263
|
return result.code === 0;
|
|
246
264
|
}
|
|
247
265
|
export async function commentOnPr(repo, pr, body) {
|
|
248
|
-
await
|
|
266
|
+
await ghOnce(repo, ["pr", "comment", String(pr), "--body-file", "-"], body);
|
|
249
267
|
}
|