co-maintainer 0.7.10-beta.1 → 0.7.10-beta.2
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/package.json +1 -1
- package/dist/src/cli/commands/review.js +1 -0
- package/dist/src/cli/review_github.d.ts +7 -1
- package/dist/src/cli/review_github.js +19 -5
- package/dist/src/local/review_local.js +1 -0
- package/dist/src/pr/checkout.d.ts +5 -0
- package/dist/src/pr/checkout.js +13 -2
- package/dist/src/pr/scope.js +2 -2
- package/dist/src/remote/client.js +1 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -13,7 +13,10 @@ export declare function escapeProperty(value: string): string;
|
|
|
13
13
|
/** One workflow command per finding still standing, errors first. A finding
|
|
14
14
|
* that was closed since the last review needs no annotation. The dropped
|
|
15
15
|
* files warning takes one of the warning slots. */
|
|
16
|
-
export declare function githubAnnotations(findings: HumanFinding[], coverage?: Coverage
|
|
16
|
+
export declare function githubAnnotations(findings: HumanFinding[], coverage?: Coverage,
|
|
17
|
+
/** Name each finding's rules, only when the repository turned references
|
|
18
|
+
* on, as the terminal output does. */
|
|
19
|
+
showReferences?: boolean): string[];
|
|
17
20
|
export type GithubSummaryInput = {
|
|
18
21
|
/** What was reviewed, for the line under the heading. */
|
|
19
22
|
title: string;
|
|
@@ -30,6 +33,9 @@ export type GithubSummaryInput = {
|
|
|
30
33
|
/** The extensions' results. Their findings join the table, and their
|
|
31
34
|
* `markdown` follows the AI part. */
|
|
32
35
|
extensions?: ExtensionReport;
|
|
36
|
+
/** Name each finding's rules in its annotation. On only when the
|
|
37
|
+
* repository turned references on. */
|
|
38
|
+
showReferences?: boolean;
|
|
33
39
|
/** An intent file was given. The summary says so and never shows the text. */
|
|
34
40
|
intent?: boolean;
|
|
35
41
|
};
|
|
@@ -27,7 +27,17 @@ export function escapeData(value) {
|
|
|
27
27
|
export function escapeProperty(value) {
|
|
28
28
|
return escapeData(value).replace(/:/g, "%3A").replace(/,/g, "%2C");
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
/** ` (rule R3)` or ` (rules R3, I1)`: the guide and instruction rules a
|
|
31
|
+
* finding rests on, so a CI annotation names them as the terminal does. */
|
|
32
|
+
function rulesNote(row) {
|
|
33
|
+
const ids = (row.references ?? []).flatMap((reference) => reference.kind === "rule" || reference.kind === "instruction"
|
|
34
|
+
? [reference.id]
|
|
35
|
+
: []);
|
|
36
|
+
if (ids.length === 0)
|
|
37
|
+
return "";
|
|
38
|
+
return ` (${ids.length === 1 ? "rule" : "rules"} ${ids.join(", ")})`;
|
|
39
|
+
}
|
|
40
|
+
function annotation(row, showReferences = false) {
|
|
31
41
|
const properties = [];
|
|
32
42
|
if (row.path) {
|
|
33
43
|
properties.push(`file=${escapeProperty(row.path)}`);
|
|
@@ -46,7 +56,8 @@ function annotation(row) {
|
|
|
46
56
|
? `${row.severity}: ${short}`
|
|
47
57
|
: `${row.severity} finding`)}`);
|
|
48
58
|
const level = row.blocking ? "error" : "warning";
|
|
49
|
-
|
|
59
|
+
const note = showReferences ? rulesNote(row) : "";
|
|
60
|
+
return `::${level} ${properties.join(",")}::${escapeData(`${row.body || row.title}${note}`)}`;
|
|
50
61
|
}
|
|
51
62
|
function active(findings) {
|
|
52
63
|
return sortHumanFindings(findings).filter((row) => row.state !== "closed");
|
|
@@ -63,7 +74,10 @@ function droppedAnnotation(coverage) {
|
|
|
63
74
|
/** One workflow command per finding still standing, errors first. A finding
|
|
64
75
|
* that was closed since the last review needs no annotation. The dropped
|
|
65
76
|
* files warning takes one of the warning slots. */
|
|
66
|
-
export function githubAnnotations(findings, coverage
|
|
77
|
+
export function githubAnnotations(findings, coverage,
|
|
78
|
+
/** Name each finding's rules, only when the repository turned references
|
|
79
|
+
* on, as the terminal output does. */
|
|
80
|
+
showReferences = false) {
|
|
67
81
|
const rows = active(findings);
|
|
68
82
|
const errors = rows.filter((row) => row.blocking);
|
|
69
83
|
const warnings = rows.filter((row) => !row.blocking);
|
|
@@ -72,7 +86,7 @@ export function githubAnnotations(findings, coverage) {
|
|
|
72
86
|
...errors.slice(0, MAX_ANNOTATIONS_PER_LEVEL),
|
|
73
87
|
...warnings.slice(0, MAX_ANNOTATIONS_PER_LEVEL - (dropped ? 1 : 0)),
|
|
74
88
|
];
|
|
75
|
-
const lines = shown.map(annotation);
|
|
89
|
+
const lines = shown.map((row) => annotation(row, showReferences));
|
|
76
90
|
if (dropped)
|
|
77
91
|
lines.push(dropped);
|
|
78
92
|
const left = rows.length - shown.length;
|
|
@@ -150,7 +164,7 @@ export function emitGithubOutput(input) {
|
|
|
150
164
|
// Only an extension finding with a location is annotated. The job summary
|
|
151
165
|
// lists the rest.
|
|
152
166
|
const located = extensionHumanFindings(input.extensions).filter((row) => row.path);
|
|
153
|
-
for (const line of githubAnnotations([...input.findings, ...located], input.coverage)) {
|
|
167
|
+
for (const line of githubAnnotations([...input.findings, ...located], input.coverage, input.showReferences)) {
|
|
154
168
|
console.log(line);
|
|
155
169
|
}
|
|
156
170
|
appendStepSummary(githubSummary(input));
|
|
@@ -24,4 +24,9 @@ export declare function ensureClone(repo: string, run: Run): Promise<string>;
|
|
|
24
24
|
* branch has moved on or the PR was squash-merged, so no local or
|
|
25
25
|
* remote-tracking ref points at it any more. */
|
|
26
26
|
export declare function ensureCommit(clone: string, revision: string, run: Run): Promise<string>;
|
|
27
|
+
/** `run` for git commands inside `clone` that may reach GitHub. The clone is
|
|
28
|
+
* blobless, so a worktree, a checkout or a `git show` downloads file contents
|
|
29
|
+
* on demand, and on a private repository that needs the App's token as much
|
|
30
|
+
* as the clone did. */
|
|
31
|
+
export declare function withGitAuth(run: Run, clone: string): Run;
|
|
27
32
|
export declare function ensureWorktree(repo: string, pr: number, commit: string, run: Run): Promise<string>;
|
package/dist/src/pr/checkout.js
CHANGED
|
@@ -136,21 +136,32 @@ export async function ensureCommit(clone, revision, run) {
|
|
|
136
136
|
}
|
|
137
137
|
return sha;
|
|
138
138
|
}
|
|
139
|
+
/** `run` for git commands inside `clone` that may reach GitHub. The clone is
|
|
140
|
+
* blobless, so a worktree, a checkout or a `git show` downloads file contents
|
|
141
|
+
* on demand, and on a private repository that needs the App's token as much
|
|
142
|
+
* as the clone did. */
|
|
143
|
+
export function withGitAuth(run, clone) {
|
|
144
|
+
return async (command, args, cwd, env) => {
|
|
145
|
+
const auth = await gitAuthEnv(clone);
|
|
146
|
+
return run(command, args, cwd, auth || env ? { ...auth, ...env } : undefined);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
139
149
|
export async function ensureWorktree(repo, pr, commit, run) {
|
|
140
150
|
return withCloneLock(repo, async () => {
|
|
141
151
|
const clone = await ensureCloneUnlocked(repo, run);
|
|
142
152
|
const sha = await ensureCommit(clone, commit, run);
|
|
143
153
|
const dir = worktreeDir(repo, pr);
|
|
154
|
+
const git = withGitAuth(run, clone);
|
|
144
155
|
if (await pathExists(`${dir}/.git`)) {
|
|
145
156
|
log("checkout", `reusing worktree ${dir}`);
|
|
146
|
-
const reset = await
|
|
157
|
+
const reset = await git("git", ["checkout", "-q", "--detach", sha], dir);
|
|
147
158
|
if (reset.code !== 0) {
|
|
148
159
|
throw new Error(`checkout ${sha} failed: ${reset.stderr.trim()}`);
|
|
149
160
|
}
|
|
150
161
|
return dir;
|
|
151
162
|
}
|
|
152
163
|
log("checkout", `creating worktree ${dir} at ${sha.slice(0, 10)}`);
|
|
153
|
-
const added = await
|
|
164
|
+
const added = await git("git", ["worktree", "add", "-q", "--detach", dir, sha], clone);
|
|
154
165
|
if (added.code !== 0) {
|
|
155
166
|
throw new Error(`git worktree add failed: ${added.stderr.trim()}`);
|
|
156
167
|
}
|
package/dist/src/pr/scope.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ensureCloneUnlocked, ensureCommit, runCommand, withCloneLock, } from "./checkout.js";
|
|
1
|
+
import { ensureCloneUnlocked, withGitAuth, ensureCommit, runCommand, withCloneLock, } from "./checkout.js";
|
|
2
2
|
import { detectDefaultBranchRef } from "../git/default_branch.js";
|
|
3
3
|
import { log } from "../util/log.js";
|
|
4
4
|
function lines(output) {
|
|
@@ -79,6 +79,6 @@ export async function computeScope(repo, base, head, options = {}) {
|
|
|
79
79
|
log("scope", `unavailable · ${String(error)}`);
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
|
-
return await scopeInClone(clone, base, head, run);
|
|
82
|
+
return await scopeInClone(clone, base, head, withGitAuth(run, clone));
|
|
83
83
|
});
|
|
84
84
|
}
|