@pecot/workflow-mcp 5.0.0 → 6.0.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/.claude-plugin/plugin.json +1 -1
- package/README.md +80 -22
- package/cli/dist/cli.js +6 -1
- package/cli/dist/commands/board-add.d.ts +3 -0
- package/cli/dist/commands/board-add.js +59 -0
- package/cli/dist/commands/board-judgment.d.ts +60 -0
- package/cli/dist/commands/board-judgment.js +144 -0
- package/cli/dist/commands/board-move.d.ts +3 -0
- package/cli/dist/commands/board-move.js +57 -0
- package/cli/dist/commands/board-readiness.d.ts +34 -0
- package/cli/dist/commands/board-readiness.js +108 -0
- package/cli/dist/commands/board-show.d.ts +3 -0
- package/cli/dist/commands/board-show.js +72 -0
- package/cli/dist/commands/board-sync.d.ts +3 -0
- package/cli/dist/commands/board-sync.js +111 -0
- package/cli/dist/commands/{project-info.d.ts → board-view.d.ts} +21 -7
- package/cli/dist/commands/{project-info.js → board-view.js} +22 -12
- package/cli/dist/commands/board.d.ts +3 -0
- package/cli/dist/commands/board.js +12 -0
- package/cli/dist/commands/branch.d.ts +3 -0
- package/cli/dist/commands/branch.js +100 -0
- package/cli/dist/commands/command-binding.js +4 -0
- package/cli/dist/commands/command-definition.d.ts +20 -6
- package/cli/dist/commands/command-definition.js +11 -7
- package/cli/dist/commands/command-help.js +2 -2
- package/cli/dist/commands/command-hint.d.ts +5 -0
- package/cli/dist/commands/command-hint.js +13 -0
- package/cli/dist/commands/command-stop.d.ts +5 -3
- package/cli/dist/commands/command-stop.js +7 -6
- package/cli/dist/commands/failure-kind.d.ts +3 -0
- package/cli/dist/commands/failure-kind.js +34 -0
- package/cli/dist/commands/failure.d.ts +6 -0
- package/cli/dist/commands/failure.js +29 -3
- package/cli/dist/commands/github-client.d.ts +6 -2
- package/cli/dist/commands/github-client.js +13 -3
- package/cli/dist/commands/help.js +8 -13
- package/cli/dist/commands/issue-board.d.ts +33 -0
- package/cli/dist/commands/issue-board.js +61 -1
- package/cli/dist/commands/issue-comment.js +47 -28
- package/cli/dist/commands/issue-create.js +548 -91
- package/cli/dist/commands/issue-dependency.d.ts +3 -0
- package/cli/dist/commands/issue-dependency.js +282 -0
- package/cli/dist/commands/issue-readiness.d.ts +94 -0
- package/cli/dist/commands/issue-readiness.js +218 -0
- package/cli/dist/commands/issue-reopen.d.ts +3 -0
- package/cli/dist/commands/issue-reopen.js +115 -0
- package/cli/dist/commands/issue-shared.d.ts +32 -19
- package/cli/dist/commands/issue-shared.js +82 -75
- package/cli/dist/commands/issue-show.d.ts +3 -0
- package/cli/dist/commands/issue-show.js +169 -0
- package/cli/dist/commands/issue.d.ts +0 -1
- package/cli/dist/commands/issue.js +6 -8
- package/cli/dist/commands/names.d.ts +33 -0
- package/cli/dist/commands/names.js +62 -0
- package/cli/dist/commands/output.d.ts +14 -2
- package/cli/dist/commands/output.js +14 -7
- package/cli/dist/commands/pr-waiting.d.ts +20 -0
- package/cli/dist/commands/pr-waiting.js +106 -0
- package/cli/dist/commands/pr.d.ts +19 -0
- package/cli/dist/commands/pr.js +242 -323
- package/cli/dist/commands/project-sync.d.ts +2 -1
- package/cli/dist/commands/project-sync.js +18 -9
- package/cli/dist/commands/project.d.ts +3 -2
- package/cli/dist/commands/project.js +212 -175
- package/cli/dist/commands/registry.js +13 -10
- package/cli/dist/commands/release.d.ts +2 -2
- package/cli/dist/commands/release.js +53 -114
- package/cli/dist/commands/renamed-commands.d.ts +26 -0
- package/cli/dist/commands/renamed-commands.js +53 -0
- package/cli/dist/commands/repository-match.js +3 -2
- package/cli/dist/commands/session-finish.d.ts +3 -0
- package/cli/dist/commands/session-finish.js +267 -0
- package/cli/dist/commands/session-start.d.ts +3 -0
- package/cli/dist/commands/{repository.js → session-start.js} +99 -128
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +82 -29
- package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
- package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +57 -66
- package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
- package/cli/dist/commands/{security.js → tracker-sync-security.js} +50 -61
- package/cli/dist/commands/tracker-sync.d.ts +7 -0
- package/cli/dist/commands/tracker-sync.js +3 -6
- package/cli/dist/commands/tracker.d.ts +3 -0
- package/cli/dist/commands/tracker.js +18 -0
- package/cli/dist/commands/usage-error.d.ts +4 -0
- package/cli/dist/commands/usage-error.js +6 -0
- package/cli/dist/commands/work-target.d.ts +12 -3
- package/cli/dist/commands/work-target.js +46 -5
- package/cli/dist/commands/worktree.js +32 -28
- package/cli/dist/domain/batch-plan.d.ts +73 -0
- package/cli/dist/domain/batch-plan.js +114 -0
- package/cli/dist/domain/blocked-by-change.d.ts +99 -0
- package/cli/dist/domain/blocked-by-change.js +101 -0
- package/cli/dist/domain/board-move.d.ts +90 -0
- package/cli/dist/domain/board-move.js +92 -0
- package/cli/dist/domain/branch-name.js +1 -1
- package/cli/dist/domain/command-hint.d.ts +85 -0
- package/cli/dist/domain/command-hint.js +148 -0
- package/cli/dist/domain/config.d.ts +4 -0
- package/cli/dist/domain/config.js +11 -1
- package/cli/dist/domain/dependabot.js +1 -1
- package/cli/dist/domain/errors.d.ts +5 -0
- package/cli/dist/domain/errors.js +5 -0
- package/cli/dist/domain/format.d.ts +51 -4
- package/cli/dist/domain/format.js +72 -6
- package/cli/dist/domain/frontmatter.d.ts +18 -3
- package/cli/dist/domain/frontmatter.js +38 -12
- package/cli/dist/domain/issue-order.d.ts +55 -0
- package/cli/dist/domain/issue-order.js +65 -0
- package/cli/dist/domain/issue-readout.d.ts +36 -0
- package/cli/dist/domain/pull-request.d.ts +71 -4
- package/cli/dist/domain/pull-request.js +59 -10
- package/cli/dist/domain/readiness.d.ts +27 -0
- package/cli/dist/domain/readiness.js +114 -3
- package/cli/dist/domain/reference-parser.d.ts +3 -1
- package/cli/dist/domain/reference-parser.js +6 -2
- package/cli/dist/domain/release.d.ts +7 -3
- package/cli/dist/domain/release.js +5 -12
- package/cli/dist/domain/repository-policy.d.ts +9 -3
- package/cli/dist/domain/repository-policy.js +8 -7
- package/cli/dist/domain/repository-resolver.js +4 -1
- package/cli/dist/domain/security-alerts.js +1 -1
- package/cli/dist/domain/state.d.ts +30 -0
- package/cli/dist/domain/state.js +39 -0
- package/cli/dist/domain/work-start.d.ts +34 -0
- package/cli/dist/domain/work-start.js +49 -0
- package/cli/dist/infra/authored-notes.d.ts +1 -1
- package/cli/dist/infra/authored-notes.js +10 -4
- package/cli/dist/infra/config-store.d.ts +4 -0
- package/cli/dist/infra/config-store.js +13 -0
- package/cli/dist/infra/git.d.ts +12 -0
- package/cli/dist/infra/git.js +13 -1
- package/cli/dist/infra/github/client.d.ts +5 -0
- package/cli/dist/infra/github/client.js +10 -7
- package/cli/dist/infra/github/errors.d.ts +18 -0
- package/cli/dist/infra/github/errors.js +22 -0
- package/cli/dist/infra/github/issues.d.ts +39 -3
- package/cli/dist/infra/github/issues.js +178 -23
- package/cli/dist/infra/github/projects.d.ts +35 -0
- package/cli/dist/infra/github/projects.js +89 -8
- package/cli/dist/infra/github/pulls.d.ts +24 -0
- package/cli/dist/infra/github/pulls.js +56 -0
- package/cli/dist/infra/github/queries.d.ts +12 -4
- package/cli/dist/infra/github/queries.js +156 -8
- package/cli/dist/infra/github/readout.d.ts +5 -1
- package/cli/dist/infra/github/readout.js +11 -0
- package/cli/dist/infra/github/repos.d.ts +18 -0
- package/cli/dist/infra/github/repos.js +31 -0
- package/cli/dist/infra/nx-scope.d.ts +1 -1
- package/cli/dist/infra/nx-scope.js +1 -1
- package/cli/dist/infra/state-store.d.ts +10 -1
- package/cli/dist/infra/state-store.js +14 -2
- package/cli/dist/infra/worktree-links.d.ts +3 -0
- package/cli/dist/infra/worktree-links.js +8 -1
- package/cli/dist/infra/worktree.d.ts +12 -1
- package/cli/dist/infra/worktree.js +40 -23
- package/cli/dist/mcp/result.d.ts +34 -6
- package/cli/dist/mcp/result.js +62 -18
- package/cli/dist/mcp/server.d.ts +2 -2
- package/cli/dist/mcp/server.js +24 -10
- package/cli/templates/comment/plan.md +14 -0
- package/cli/templates/issue/bug.md +1 -1
- package/cli/templates/issue/task-implement.md +13 -6
- package/cli/templates/issue/task.md +1 -1
- package/cli/templates/workflow/pecot-board-sync.yml +84 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/cli/dist/commands/dependabot.d.ts +0 -3
- package/cli/dist/commands/issue-project.d.ts +0 -3
- package/cli/dist/commands/issue-project.js +0 -176
- package/cli/dist/commands/issue-quick.d.ts +0 -3
- package/cli/dist/commands/issue-quick.js +0 -126
- package/cli/dist/commands/issue-read.d.ts +0 -3
- package/cli/dist/commands/issue-read.js +0 -80
- package/cli/dist/commands/repository.d.ts +0 -5
- package/cli/dist/commands/security.d.ts +0 -3
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// 作業対象(.pecot-active と .pecot-session-title、作業ディレクトリ)を記録して、結果の行を出す。
|
|
2
2
|
import { InvalidValueError, ProjectRootNotFoundError } from '../domain/errors.js';
|
|
3
|
+
import { FLAG_PECOT_BASE } from '../domain/state.js';
|
|
3
4
|
import { OsError, hasErrorCode, toOsError } from '../infra/os-error.js';
|
|
4
5
|
import { WORK_DIR } from '../infra/paths.js';
|
|
5
|
-
import { ensureWorkDirectory, writeWorkTarget } from '../infra/state-store.js';
|
|
6
|
+
import { ensureWorkDirectory, removeFlag, writeBaseRecord, writeWorkTarget } from '../infra/state-store.js';
|
|
6
7
|
import { stopWith } from './command-stop.js';
|
|
7
8
|
/**
|
|
8
9
|
記録の失敗として扱う例外か。OS の失敗・値の誤り・プロジェクトルート不明。プログラムの誤りは伝える
|
|
@@ -15,11 +16,12 @@ function describeFailure(error) {
|
|
|
15
16
|
return converted instanceof Error ? converted.message : error.message;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
.pecot-
|
|
19
|
-
失敗は warning
|
|
19
|
+
.pecot-base を消してから作業対象を書き、`set: work target ...` の行を出す。options.base があれば記録後に .pecot-base も書く。
|
|
20
|
+
失敗は warning の行。failWithExit なら error の行と CommandExit(1)。記録できたかを返す
|
|
20
21
|
*/
|
|
21
22
|
export function recordWorkTarget(out, owner, repository, issueNumber, title, options = {}) {
|
|
22
23
|
const issueReference = `${owner}/${repository}/${String(issueNumber)}`;
|
|
24
|
+
clearBase(out);
|
|
23
25
|
let target;
|
|
24
26
|
try {
|
|
25
27
|
writeWorkTarget(issueReference, title);
|
|
@@ -31,11 +33,50 @@ export function recordWorkTarget(out, owner, repository, issueNumber, title, opt
|
|
|
31
33
|
if (!isRecordingFailure(error))
|
|
32
34
|
throw error;
|
|
33
35
|
if (options.failWithExit === true) {
|
|
34
|
-
stopWith(out, `could not record the work target: ${describeFailure(error)}
|
|
36
|
+
stopWith(out, `could not record the work target: ${describeFailure(error)}`, 'other');
|
|
35
37
|
}
|
|
36
38
|
out.warning(`could not record the work target: ${describeFailure(error)}`);
|
|
37
|
-
return;
|
|
39
|
+
return 'failed';
|
|
38
40
|
}
|
|
39
41
|
out.done({ verb: 'set', target });
|
|
42
|
+
if (options.base !== undefined)
|
|
43
|
+
recordBase(options.base, out);
|
|
44
|
+
return 'recorded';
|
|
45
|
+
}
|
|
46
|
+
function warnBase(out, error) {
|
|
47
|
+
if (!isRecordingFailure(error))
|
|
48
|
+
throw error;
|
|
49
|
+
out.warning(`could not record the base: ${describeFailure(error)}`);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
前の作業対象の .pecot-base を消す。消せなければ warning の行を出して続ける
|
|
53
|
+
*/
|
|
54
|
+
function clearBase(out) {
|
|
55
|
+
try {
|
|
56
|
+
removeFlag(FLAG_PECOT_BASE);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
// 状態ディレクトリが無い(ENOTDIR)なら消すものが無い。書くほうの失敗が別に出る
|
|
60
|
+
if (hasErrorCode(error) && error.code === 'ENOTDIR')
|
|
61
|
+
return;
|
|
62
|
+
warnBase(out, error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
.pecot-base を書く。書けなければ warning の行を出して続ける
|
|
67
|
+
*/
|
|
68
|
+
function recordBase(record, out) {
|
|
69
|
+
try {
|
|
70
|
+
writeBaseRecord(record);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
warnBase(out, error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
予行の行。recordWorkTarget が書く作業対象(.pecot-active・.pecot-session-title・.pecot-base)を書かずに出す
|
|
78
|
+
*/
|
|
79
|
+
export function planWorkTarget(out, owner, repository, issueNumber) {
|
|
80
|
+
out.planned({ verb: 'set', target: `work target ${owner}/${repository}/${String(issueNumber)}` });
|
|
40
81
|
}
|
|
41
82
|
//# sourceMappingURL=work-target.js.map
|
|
@@ -13,9 +13,10 @@ import { createWorktree, detectProjectRoot, ensureDevcontainerEnvironment, findM
|
|
|
13
13
|
import { createSymlinksSafe, DEFAULT_WORKTREEIGNORE_CONTENT, decideOverwrite, getDefaultConfig, loadConfig, planLink, saveConfig, WorktreeConfigError, } from '../infra/worktree-links.js';
|
|
14
14
|
import { createOutput, isConfirmed } from './output.js';
|
|
15
15
|
import { defineCommand } from './command-definition.js';
|
|
16
|
+
import { commandHint, hinted, hintedTextOf, inputHint, placeholder } from './command-hint.js';
|
|
17
|
+
import { stopWith } from './command-stop.js';
|
|
16
18
|
import { directorySchema } from './directory-option.js';
|
|
17
19
|
import { requireRepositoryMatch } from './repository-match.js';
|
|
18
|
-
const FAILURE = 1;
|
|
19
20
|
// click の realpath と同じく、解決できない所は字面のまま残して投げない
|
|
20
21
|
function lenientRealPath(value) {
|
|
21
22
|
try {
|
|
@@ -32,8 +33,7 @@ const dryRunInput = z.boolean().default(false).describe('Show what would happen
|
|
|
32
33
|
function reportRuntimeError(out, error) {
|
|
33
34
|
if (!(error instanceof WorktreeRuntimeError))
|
|
34
35
|
throw error;
|
|
35
|
-
out
|
|
36
|
-
return FAILURE;
|
|
36
|
+
return stopWith(out, hintedTextOf(error) ?? error.message, error.failure);
|
|
37
37
|
}
|
|
38
38
|
function countLinkResults(results, out) {
|
|
39
39
|
out.count('symlinks created', results.filter(result => result.action === 'created').length);
|
|
@@ -109,23 +109,31 @@ const worktreeRemoveInput = z.object({
|
|
|
109
109
|
directory: directorySchema,
|
|
110
110
|
force: z.boolean().default(false).describe('Force removal even if there are changes'),
|
|
111
111
|
keep_branch: z.boolean().default(false).describe('Keep the branch'),
|
|
112
|
+
dry_run: dryRunInput,
|
|
112
113
|
});
|
|
113
114
|
const worktreeRemoveCommand = defineCommand({
|
|
114
115
|
path: ['worktree', 'remove'],
|
|
115
116
|
description: 'Remove a worktree',
|
|
116
117
|
input: worktreeRemoveInput,
|
|
117
118
|
positional: ['name'],
|
|
118
|
-
shortFlags: { directory: '-D' },
|
|
119
|
+
shortFlags: { directory: '-D', dry_run: '-n' },
|
|
119
120
|
interactive: false,
|
|
120
121
|
run: (input, io) => Promise.resolve(runRemove(input, io)),
|
|
121
122
|
});
|
|
122
123
|
function runRemove(input, io) {
|
|
123
124
|
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
124
|
-
const out = createOutput(
|
|
125
|
+
const out = createOutput(input.dry_run, io);
|
|
125
126
|
try {
|
|
126
127
|
ensureDevcontainerEnvironment();
|
|
127
|
-
const branchError = removeWorktree(input.directory, input.name, out, { isForced: input.force, shouldKeepBranch: input.keep_branch });
|
|
128
|
-
|
|
128
|
+
const branchError = removeWorktree(input.directory, input.name, out, { isForced: input.force, shouldKeepBranch: input.keep_branch, isDryRun: input.dry_run });
|
|
129
|
+
const removed = { verb: 'remove', target: `worktree ${input.name}` };
|
|
130
|
+
out.planned(removed);
|
|
131
|
+
out.done(removed);
|
|
132
|
+
if (input.dry_run) {
|
|
133
|
+
if (!input.keep_branch)
|
|
134
|
+
out.planned({ verb: 'delete', target: `local branch ${input.name}` });
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
129
137
|
if (!input.keep_branch) {
|
|
130
138
|
if (branchError === undefined)
|
|
131
139
|
out.done({ verb: 'delete', target: `local branch ${input.name}` });
|
|
@@ -138,13 +146,13 @@ function runRemove(input, io) {
|
|
|
138
146
|
return reportRuntimeError(out, error);
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
|
-
const worktreeInitInput = z.object({ directory: directorySchema });
|
|
149
|
+
const worktreeInitInput = z.object({ directory: directorySchema, dry_run: dryRunInput });
|
|
142
150
|
const worktreeInitCommand = defineCommand({
|
|
143
151
|
path: ['worktree', 'init'],
|
|
144
152
|
description: 'Create the worktree config files in the main worktree',
|
|
145
153
|
input: worktreeInitInput,
|
|
146
154
|
positional: [],
|
|
147
|
-
shortFlags: { directory: '-D' },
|
|
155
|
+
shortFlags: { directory: '-D', dry_run: '-n' },
|
|
148
156
|
interactive: false,
|
|
149
157
|
run: (input, io) => Promise.resolve(runInit(input, io)),
|
|
150
158
|
});
|
|
@@ -168,7 +176,7 @@ function writeInitFiles(configFile, ignoreFile, config, out) {
|
|
|
168
176
|
}
|
|
169
177
|
function runInit(input, io) {
|
|
170
178
|
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
171
|
-
const out = createOutput(
|
|
179
|
+
const out = createOutput(input.dry_run, io);
|
|
172
180
|
let mainWorktree;
|
|
173
181
|
try {
|
|
174
182
|
ensureDevcontainerEnvironment();
|
|
@@ -180,10 +188,8 @@ function runInit(input, io) {
|
|
|
180
188
|
const configFile = path.join(mainWorktree, WORKTREE_CONFIG_FILENAME);
|
|
181
189
|
const ignoreFile = path.join(mainWorktree, WORKTREE_IGNORE_FILENAME);
|
|
182
190
|
const existing = [configFile, ignoreFile].filter(file => isExistingFile(file));
|
|
183
|
-
if (existing.length > 0)
|
|
184
|
-
out
|
|
185
|
-
return FAILURE;
|
|
186
|
-
}
|
|
191
|
+
if (existing.length > 0)
|
|
192
|
+
stopWith(out, ['worktree config already exists', ...existing].join('\n'), 'already-exists');
|
|
187
193
|
let targetRepository;
|
|
188
194
|
try {
|
|
189
195
|
targetRepository = sharedLinkTarget(mainWorktree);
|
|
@@ -191,8 +197,12 @@ function runInit(input, io) {
|
|
|
191
197
|
catch (error) {
|
|
192
198
|
if (!(error instanceof InvalidValueError || error instanceof OsError || error instanceof ConfigError))
|
|
193
199
|
throw error;
|
|
194
|
-
out
|
|
195
|
-
|
|
200
|
+
return stopWith(out, `could not read the active config: ${error.message}`, 'config-invalid');
|
|
201
|
+
}
|
|
202
|
+
if (input.dry_run) {
|
|
203
|
+
out.planned({ verb: 'create', target: `worktree config ${configFile}` });
|
|
204
|
+
out.planned({ verb: 'create', target: `worktree ignore file ${ignoreFile}` });
|
|
205
|
+
return 0;
|
|
196
206
|
}
|
|
197
207
|
writeInitFiles(configFile, ignoreFile, getDefaultConfig(targetRepository, path.basename(mainWorktree)), out);
|
|
198
208
|
return 0;
|
|
@@ -287,18 +297,14 @@ function runLink(input, io) {
|
|
|
287
297
|
try {
|
|
288
298
|
ensureDevcontainerEnvironment();
|
|
289
299
|
const configFile = findWorktreeConfigFile(input.directory);
|
|
290
|
-
if (configFile === undefined)
|
|
291
|
-
out
|
|
292
|
-
return FAILURE;
|
|
293
|
-
}
|
|
300
|
+
if (configFile === undefined)
|
|
301
|
+
stopWith(out, hinted `worktree config not found\nrun: ${commandHint(['worktree', 'init'], { directory: placeholder('directory') })}`, 'not-initialized');
|
|
294
302
|
const config = loadConfig(configFile);
|
|
295
303
|
const mainWorktree = findMainWorktree(input.directory);
|
|
296
304
|
const projectRoot = detectProjectRoot(input.directory);
|
|
297
305
|
const resolved = linkTargets(input.directory, mainWorktree, input.all);
|
|
298
|
-
if (resolved.kind === 'main-needs-all')
|
|
299
|
-
out
|
|
300
|
-
return FAILURE;
|
|
301
|
-
}
|
|
306
|
+
if (resolved.kind === 'main-needs-all')
|
|
307
|
+
stopWith(out, hinted `use ${inputHint(['worktree', 'link'], 'all')} in the main worktree`, 'invalid-input');
|
|
302
308
|
const targets = resolved.directories;
|
|
303
309
|
if (targets.length === 0) {
|
|
304
310
|
out.count('sub-worktrees', 0);
|
|
@@ -324,10 +330,8 @@ function runLink(input, io) {
|
|
|
324
330
|
return 0;
|
|
325
331
|
}
|
|
326
332
|
catch (error) {
|
|
327
|
-
if (error instanceof WorktreeConfigError)
|
|
328
|
-
out
|
|
329
|
-
return FAILURE;
|
|
330
|
-
}
|
|
333
|
+
if (error instanceof WorktreeConfigError)
|
|
334
|
+
stopWith(out, error.message, 'config-invalid');
|
|
331
335
|
return reportRuntimeError(out, error);
|
|
332
336
|
}
|
|
333
337
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Progression, Wait } from './readiness.js';
|
|
2
|
+
import type { IssueReference } from './reference-parser.js';
|
|
3
|
+
import type { RepositoryReference } from './repository-resolver.js';
|
|
4
|
+
export interface BatchEntry {
|
|
5
|
+
readonly issue: string;
|
|
6
|
+
readonly wait: Wait;
|
|
7
|
+
readonly reason: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface BatchFile {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
代表のキー。suffix があれば suffix、無ければ幹
|
|
13
|
+
*/
|
|
14
|
+
readonly key: string;
|
|
15
|
+
/**
|
|
16
|
+
前提に書けるキーすべて(幹と suffix)
|
|
17
|
+
*/
|
|
18
|
+
readonly keys: readonly string[];
|
|
19
|
+
readonly blockedBy: readonly BatchEntry[];
|
|
20
|
+
}
|
|
21
|
+
export type PrerequisiteTarget = {
|
|
22
|
+
readonly kind: 'file';
|
|
23
|
+
readonly index: number;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'existing';
|
|
26
|
+
readonly reference: IssueReference;
|
|
27
|
+
};
|
|
28
|
+
export interface ResolvedPrerequisite {
|
|
29
|
+
readonly target: PrerequisiteTarget;
|
|
30
|
+
/**
|
|
31
|
+
進め方の判定に使うキー。ファイルは代表のキー、既存の Issue は issueReferenceKey
|
|
32
|
+
*/
|
|
33
|
+
readonly key: string;
|
|
34
|
+
readonly wait: Wait;
|
|
35
|
+
readonly reason: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
export type BatchResolution = {
|
|
38
|
+
readonly kind: 'ok';
|
|
39
|
+
/**
|
|
40
|
+
ファイルごとの、書いた順の前提
|
|
41
|
+
*/
|
|
42
|
+
readonly prerequisites: readonly (readonly ResolvedPrerequisite[])[];
|
|
43
|
+
/**
|
|
44
|
+
キー(ファイルの代表のキー、既存の Issue は issueReferenceKey)→ 進め方
|
|
45
|
+
*/
|
|
46
|
+
readonly progressions: ReadonlyMap<string, Progression>;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'error';
|
|
49
|
+
readonly message: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
前提を解決して確かめる。順は、知らないキー → 輪 → 後ろのファイル → 同じ相手を 2 回指す前提。
|
|
53
|
+
輪はファイルどうしの前提だけで探す(新しい Issue を前提に持つ既存の Issue は無い)
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveBatch(files: readonly BatchFile[]): BatchResolution;
|
|
56
|
+
export interface PlanRow {
|
|
57
|
+
readonly file: string;
|
|
58
|
+
/**
|
|
59
|
+
親 Epic の無いファイルは undefined
|
|
60
|
+
*/
|
|
61
|
+
readonly order: number | undefined;
|
|
62
|
+
readonly prerequisites: readonly ResolvedPrerequisite[];
|
|
63
|
+
readonly progression: Progression | undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
`--plan` の表。列は File・Number・Blocked by・Approach。既存の Issue の表記は、一括の先頭のファイルのリポジトリ home を基準にする
|
|
67
|
+
*/
|
|
68
|
+
export declare function formatPlanTable(rows: readonly PlanRow[], home: RepositoryReference): string;
|
|
69
|
+
/**
|
|
70
|
+
積める並び。キーを label で表記に直し、並びが無ければ undefined。並びは `Stackable chains:` の見出しと `- a -> b` の行にする
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatStackableChains(progressions: ReadonlyMap<string, Progression>, label: (key: string) => string): string | undefined;
|
|
73
|
+
//# sourceMappingURL=batch-plan.d.ts.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// 一括投稿の前提の確認と、進め方の表(specs/024 の contracts/cli-commands.md の `pecot issue create`)。I/O を持たない。
|
|
2
|
+
import { displayReference, planProgression, stackChains } from './readiness.js';
|
|
3
|
+
import { issueReferenceKey, issueReferenceToCliReference, parseIssueReference, ReferenceParseError } from './reference-parser.js';
|
|
4
|
+
// `owner/repo/N` の形なら既存の Issue。これに当たらない値は、一括の中のファイルのキーとして探す
|
|
5
|
+
function existingReference(raw) {
|
|
6
|
+
try {
|
|
7
|
+
return parseIssueReference(raw);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error instanceof ReferenceParseError)
|
|
11
|
+
return undefined;
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// 前提の書いたキーを、一括の中のファイルか既存の Issue に解く。どちらでもないキーがあれば、その message を返す
|
|
16
|
+
function resolveTargets(files) {
|
|
17
|
+
const owners = new Map(files.flatMap((file, index) => file.keys.map((key) => [key, { index, key: file.key }])));
|
|
18
|
+
const prerequisites = [];
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const resolved = [];
|
|
21
|
+
for (const entry of file.blockedBy) {
|
|
22
|
+
const reference = existingReference(entry.issue);
|
|
23
|
+
const owner = owners.get(entry.issue);
|
|
24
|
+
if (reference !== undefined)
|
|
25
|
+
resolved.push({ target: { kind: 'existing', reference }, key: issueReferenceKey(reference), wait: entry.wait, reason: entry.reason });
|
|
26
|
+
else if (owner === undefined)
|
|
27
|
+
return { message: `blocked_by in ${file.name} refers to unknown key ${entry.issue}` };
|
|
28
|
+
else
|
|
29
|
+
resolved.push({ target: { kind: 'file', index: owner.index }, key: owner.key, wait: entry.wait, reason: entry.reason });
|
|
30
|
+
}
|
|
31
|
+
prerequisites.push(resolved);
|
|
32
|
+
}
|
|
33
|
+
return { prerequisites };
|
|
34
|
+
}
|
|
35
|
+
// 前提を書いたキーの表記。ファイルは代表のキー、既存の Issue は `owner/repo/N`
|
|
36
|
+
function targetLabel({ target, key }) {
|
|
37
|
+
return target.kind === 'file' ? key : issueReferenceToCliReference(target.reference);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
前提を解決して確かめる。順は、知らないキー → 輪 → 後ろのファイル → 同じ相手を 2 回指す前提。
|
|
41
|
+
輪はファイルどうしの前提だけで探す(新しい Issue を前提に持つ既存の Issue は無い)
|
|
42
|
+
*/
|
|
43
|
+
export function resolveBatch(files) {
|
|
44
|
+
const resolved = resolveTargets(files);
|
|
45
|
+
if ('message' in resolved)
|
|
46
|
+
return { kind: 'error', message: resolved.message };
|
|
47
|
+
const { prerequisites } = resolved;
|
|
48
|
+
const plan = planProgression(files.map((file, index) => ({
|
|
49
|
+
key: file.key,
|
|
50
|
+
prerequisites: (prerequisites.at(index) ?? []).map(({ key, wait }) => ({ key, wait })),
|
|
51
|
+
})));
|
|
52
|
+
if (plan.kind === 'cycle')
|
|
53
|
+
return { kind: 'error', message: `blocked_by forms a cycle: ${plan.cycle.join(' -> ')}` };
|
|
54
|
+
for (const [index, file] of files.entries()) {
|
|
55
|
+
const own = prerequisites.at(index) ?? [];
|
|
56
|
+
const later = own.find(({ target }) => target.kind === 'file' && target.index > index);
|
|
57
|
+
if (later !== undefined)
|
|
58
|
+
return { kind: 'error', message: `blocked_by in ${file.name} refers to ${targetLabel(later)}, which comes later` };
|
|
59
|
+
const seen = new Set();
|
|
60
|
+
for (const prerequisite of own) {
|
|
61
|
+
if (seen.has(prerequisite.key))
|
|
62
|
+
return { kind: 'error', message: `blocked_by in ${file.name} refers to ${targetLabel(prerequisite)} more than once` };
|
|
63
|
+
seen.add(prerequisite.key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { kind: 'ok', prerequisites, progressions: plan.progressions };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
進め方の表に出すキーの表記。ファイルは代表のキー、既存の Issue は home と同じリポジトリなら `#N`、別なら `owner/repo#N`
|
|
70
|
+
*/
|
|
71
|
+
function displayTarget({ target, key }, home) {
|
|
72
|
+
return target.kind === 'file' ? key : displayReference(target.reference, home);
|
|
73
|
+
}
|
|
74
|
+
function approachOf(row, labelOf) {
|
|
75
|
+
const { progression } = row;
|
|
76
|
+
switch (progression?.kind) {
|
|
77
|
+
case undefined:
|
|
78
|
+
case 'alone': {
|
|
79
|
+
return 'alone';
|
|
80
|
+
}
|
|
81
|
+
case 'wait-merge': {
|
|
82
|
+
return `wait for merge of ${row.prerequisites.filter(({ wait }) => wait === 'merge').map(prerequisite => labelOf(prerequisite)).join(', ')}`;
|
|
83
|
+
}
|
|
84
|
+
case 'join': {
|
|
85
|
+
return `join (wait for ${row.prerequisites.map(prerequisite => labelOf(prerequisite)).join(', ')})`;
|
|
86
|
+
}
|
|
87
|
+
case 'stack': {
|
|
88
|
+
const on = row.prerequisites.find(({ key }) => key === progression.on);
|
|
89
|
+
return `stack on ${on === undefined ? progression.on : labelOf(on)}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
`--plan` の表。列は File・Number・Blocked by・Approach。既存の Issue の表記は、一括の先頭のファイルのリポジトリ home を基準にする
|
|
95
|
+
*/
|
|
96
|
+
export function formatPlanTable(rows, home) {
|
|
97
|
+
const lines = ['| File | Number | Blocked by | Approach |', '|---|---|---|---|'];
|
|
98
|
+
const labelOf = (prerequisite) => displayTarget(prerequisite, home);
|
|
99
|
+
for (const row of rows) {
|
|
100
|
+
const blockedBy = row.prerequisites.length === 0
|
|
101
|
+
? '-'
|
|
102
|
+
: row.prerequisites.map(prerequisite => `${labelOf(prerequisite)}${prerequisite.wait === 'merge' ? ' (merge)' : ''}`).join(', ');
|
|
103
|
+
lines.push(`| ${row.file} | ${row.order === undefined ? '-' : String(row.order)} | ${blockedBy} | ${approachOf(row, labelOf)} |`);
|
|
104
|
+
}
|
|
105
|
+
return lines.join('\n');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
積める並び。キーを label で表記に直し、並びが無ければ undefined。並びは `Stackable chains:` の見出しと `- a -> b` の行にする
|
|
109
|
+
*/
|
|
110
|
+
export function formatStackableChains(progressions, label) {
|
|
111
|
+
const chains = stackChains(progressions).filter(chain => chain.length >= 2);
|
|
112
|
+
return chains.length === 0 ? undefined : ['Stackable chains:', ...chains.map(chain => `- ${chain.map(key => label(key)).join(' -> ')}`)].join('\n');
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=batch-plan.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { BlockedByReferences } from './issue-readout.js';
|
|
2
|
+
import type { Prerequisite, Wait } from './readiness.js';
|
|
3
|
+
import type { IssueReference } from './reference-parser.js';
|
|
4
|
+
import type { RepositoryReference } from './repository-resolver.js';
|
|
5
|
+
export type BlockDecision = {
|
|
6
|
+
readonly kind: 'malformed';
|
|
7
|
+
readonly reason: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'unchanged';
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'add' | 'update';
|
|
12
|
+
readonly body: string;
|
|
13
|
+
};
|
|
14
|
+
export interface BlockInput {
|
|
15
|
+
readonly body: string;
|
|
16
|
+
/**
|
|
17
|
+
待つ側の Issue のリポジトリ。本文の `#N` が指す先
|
|
18
|
+
*/
|
|
19
|
+
readonly home: RepositoryReference;
|
|
20
|
+
readonly by: IssueReference;
|
|
21
|
+
readonly wait: Wait;
|
|
22
|
+
/**
|
|
23
|
+
wait が merge のときの理由
|
|
24
|
+
*/
|
|
25
|
+
readonly reason: string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
by が、すでに blocked by に付いている
|
|
28
|
+
*/
|
|
29
|
+
readonly isLinked: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
付ける・種類を変える・何もしないのどれにするかと、書く本文を決める。
|
|
33
|
+
節が読めないときは本文を書き換えられないので malformed を返す
|
|
34
|
+
*/
|
|
35
|
+
export declare function decideBlock(input: Readonly<BlockInput>): BlockDecision;
|
|
36
|
+
export type UnblockDecision = {
|
|
37
|
+
readonly kind: 'unchanged';
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'remove';
|
|
40
|
+
readonly body: string;
|
|
41
|
+
/**
|
|
42
|
+
節が読めないときの理由。このとき body は元のまま
|
|
43
|
+
*/
|
|
44
|
+
readonly malformedReason: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
export interface UnblockInput {
|
|
47
|
+
readonly body: string;
|
|
48
|
+
readonly home: RepositoryReference;
|
|
49
|
+
readonly by: IssueReference;
|
|
50
|
+
readonly isLinked: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
外すか何もしないかを決める。付いていなければ、節に古い行が残っていても本文は書き換えない
|
|
54
|
+
*/
|
|
55
|
+
export declare function decideUnblock(input: Readonly<UnblockInput>): UnblockDecision;
|
|
56
|
+
export type ReadBlockedByLevel = (ids: readonly string[]) => Promise<ReadonlyMap<string, BlockedByReferences>>;
|
|
57
|
+
export interface CycleSearchInput {
|
|
58
|
+
readonly target: IssueReference;
|
|
59
|
+
readonly by: IssueReference;
|
|
60
|
+
readonly byId: string;
|
|
61
|
+
readonly read: ReadBlockedByLevel;
|
|
62
|
+
/**
|
|
63
|
+
たどる Issue の数の上限(by を含む)
|
|
64
|
+
*/
|
|
65
|
+
readonly limit: number;
|
|
66
|
+
}
|
|
67
|
+
export type CycleSearchResult = {
|
|
68
|
+
readonly kind: 'cycle';
|
|
69
|
+
readonly path: readonly IssueReference[];
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: 'none';
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: 'unverifiable';
|
|
74
|
+
readonly reason: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
by から blocked by を 1 段ずつたどり、target に戻れば輪として道(target → by → … → target)を返す。
|
|
78
|
+
読めない Issue・件数の不足・上限は unverifiable。GitHub は 3 つ以上の輪を通すので、確かめずに付けない
|
|
79
|
+
*/
|
|
80
|
+
export declare function searchCycle(input: Readonly<CycleSearchInput>): Promise<CycleSearchResult>;
|
|
81
|
+
export interface ExpectedPrerequisites {
|
|
82
|
+
/**
|
|
83
|
+
書いた後の前提のキー(issueReferenceKey)
|
|
84
|
+
*/
|
|
85
|
+
readonly keys: ReadonlySet<string>;
|
|
86
|
+
readonly by: IssueReference;
|
|
87
|
+
/**
|
|
88
|
+
by の種類と理由。外したときは undefined
|
|
89
|
+
*/
|
|
90
|
+
readonly wait: {
|
|
91
|
+
readonly wait: Wait;
|
|
92
|
+
readonly reason: string | undefined;
|
|
93
|
+
} | undefined;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
書いた後の読み直しが、書いた内容と一致するか。GitHub は書いた直後の読み取りの一致を保証しない
|
|
97
|
+
*/
|
|
98
|
+
export declare function hasExpectedPrerequisites(prerequisites: readonly Prerequisite[], expected: Readonly<ExpectedPrerequisites>): boolean;
|
|
99
|
+
//# sourceMappingURL=blocked-by-change.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// issue block / unblock の判断(付ける・変える・何もしない・外す)と、輪の探索。I/O は引数の関数で受ける。
|
|
2
|
+
import { InvalidValueError } from './errors.js';
|
|
3
|
+
import { readWaitsForMerge, removeWaitsForMerge, upsertWaitsForMerge } from './prerequisites.js';
|
|
4
|
+
import { displayReference } from './readiness.js';
|
|
5
|
+
import { issueReferenceKey } from './reference-parser.js';
|
|
6
|
+
function nextBody(input, hasLine, currentReason) {
|
|
7
|
+
const { body, home, by, wait, reason = '' } = input;
|
|
8
|
+
if (wait === 'stack')
|
|
9
|
+
return hasLine ? removeWaitsForMerge(body, home, by) : body;
|
|
10
|
+
const trimmed = reason.trim();
|
|
11
|
+
if (trimmed === '')
|
|
12
|
+
throw new InvalidValueError('reason is required with wait: merge');
|
|
13
|
+
return hasLine && currentReason === trimmed ? body : upsertWaitsForMerge(body, home, by, trimmed);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
付ける・種類を変える・何もしないのどれにするかと、書く本文を決める。
|
|
17
|
+
節が読めないときは本文を書き換えられないので malformed を返す
|
|
18
|
+
*/
|
|
19
|
+
export function decideBlock(input) {
|
|
20
|
+
const section = readWaitsForMerge(input.body, input.home);
|
|
21
|
+
if (section.kind === 'malformed')
|
|
22
|
+
return { kind: 'malformed', reason: section.reason };
|
|
23
|
+
const key = issueReferenceKey(input.by);
|
|
24
|
+
const line = section.kind === 'ok' ? section.lines.find(candidate => issueReferenceKey(candidate.ref) === key) : undefined;
|
|
25
|
+
const body = nextBody(input, line !== undefined, line?.reason);
|
|
26
|
+
if (!input.isLinked)
|
|
27
|
+
return { kind: 'add', body };
|
|
28
|
+
return body === input.body ? { kind: 'unchanged' } : { kind: 'update', body };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
外すか何もしないかを決める。付いていなければ、節に古い行が残っていても本文は書き換えない
|
|
32
|
+
*/
|
|
33
|
+
export function decideUnblock(input) {
|
|
34
|
+
if (!input.isLinked)
|
|
35
|
+
return { kind: 'unchanged' };
|
|
36
|
+
const section = readWaitsForMerge(input.body, input.home);
|
|
37
|
+
return section.kind === 'malformed'
|
|
38
|
+
? { kind: 'remove', body: input.body, malformedReason: section.reason }
|
|
39
|
+
: { kind: 'remove', body: removeWaitsForMerge(input.body, input.home, input.by), malformedReason: undefined };
|
|
40
|
+
}
|
|
41
|
+
function pathTo(visited, key) {
|
|
42
|
+
const chain = [];
|
|
43
|
+
for (let current = visited.get(key); current !== undefined; current = current.parentKey === undefined ? undefined : visited.get(current.parentKey)) {
|
|
44
|
+
chain.unshift(current.ref);
|
|
45
|
+
}
|
|
46
|
+
return chain;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
by から blocked by を 1 段ずつたどり、target に戻れば輪として道(target → by → … → target)を返す。
|
|
50
|
+
読めない Issue・件数の不足・上限は unverifiable。GitHub は 3 つ以上の輪を通すので、確かめずに付けない
|
|
51
|
+
*/
|
|
52
|
+
export async function searchCycle(input) {
|
|
53
|
+
const { target, by, read, limit } = input;
|
|
54
|
+
const targetKey = issueReferenceKey(target);
|
|
55
|
+
const byKey = issueReferenceKey(by);
|
|
56
|
+
const visited = new Map([[byKey, { ref: by, parentKey: undefined }]]);
|
|
57
|
+
let frontier = [{ id: input.byId, ref: by }];
|
|
58
|
+
while (frontier.length > 0) {
|
|
59
|
+
const results = await read(frontier.map(({ id }) => id));
|
|
60
|
+
const next = [];
|
|
61
|
+
for (const node of frontier) {
|
|
62
|
+
const result = results.get(node.id);
|
|
63
|
+
const label = displayReference(node.ref, target.repository);
|
|
64
|
+
if (result === undefined || result.kind === 'read-failed') {
|
|
65
|
+
return { kind: 'unverifiable', reason: `could not read blocked-by of ${label}: ${result?.reason ?? 'no result'}` };
|
|
66
|
+
}
|
|
67
|
+
if (result.total > result.issues.length) {
|
|
68
|
+
return { kind: 'unverifiable', reason: `blocked-by of ${label} has ${String(result.total)} issues, more than can be read` };
|
|
69
|
+
}
|
|
70
|
+
const nodeKey = issueReferenceKey(node.ref);
|
|
71
|
+
for (const issue of result.issues) {
|
|
72
|
+
const reference = { repository: issue.repository, number: issue.number };
|
|
73
|
+
const key = issueReferenceKey(reference);
|
|
74
|
+
if (key === targetKey)
|
|
75
|
+
return { kind: 'cycle', path: [target, ...pathTo(visited, nodeKey), target] };
|
|
76
|
+
if (visited.has(key))
|
|
77
|
+
continue;
|
|
78
|
+
if (visited.size >= limit)
|
|
79
|
+
return { kind: 'unverifiable', reason: `more than ${String(limit)} issues in the blocked-by chain` };
|
|
80
|
+
visited.set(key, { ref: reference, parentKey: nodeKey });
|
|
81
|
+
next.push({ id: issue.id, ref: reference });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
frontier = next;
|
|
85
|
+
}
|
|
86
|
+
return { kind: 'none' };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
書いた後の読み直しが、書いた内容と一致するか。GitHub は書いた直後の読み取りの一致を保証しない
|
|
90
|
+
*/
|
|
91
|
+
export function hasExpectedPrerequisites(prerequisites, expected) {
|
|
92
|
+
const keys = new Set(prerequisites.map(({ issue }) => issueReferenceKey(issue.ref)));
|
|
93
|
+
if (keys.size !== expected.keys.size || [...keys].some(key => !expected.keys.has(key)))
|
|
94
|
+
return false;
|
|
95
|
+
if (expected.wait === undefined)
|
|
96
|
+
return true;
|
|
97
|
+
const byKey = issueReferenceKey(expected.by);
|
|
98
|
+
const found = prerequisites.find(({ issue }) => issueReferenceKey(issue.ref) === byKey);
|
|
99
|
+
return found?.wait === expected.wait.wait && (found.wait === 'stack' || found.reason === expected.wait.reason);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=blocked-by-change.js.map
|