@erclx/canon 4.26.0 → 4.26.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.
|
@@ -22,7 +22,7 @@ The positional is the pull request to read, defaulting to the one open on this b
|
|
|
22
22
|
| `--root <path>` | Repository to read, defaulting to the cwd |
|
|
23
23
|
| `--json` | Add a machine-readable record on stdout, keeping the frame |
|
|
24
24
|
|
|
25
|
-
`--body` decides where both halves come from, so a number passed beside it is never read. The body comes off disk and the changed set from the local range, which is the shape a fixture and a body still being drafted both need.
|
|
25
|
+
`--body` decides where both halves come from, so a number passed beside it is never read. The body comes off disk and the changed set from the local range, which is the shape a fixture and a body still being drafted both need. A relative `--body` path resolves against the working directory the command runs from, never against `--root`. `--base` and the changed-file read still resolve against `--root`.
|
|
26
26
|
|
|
27
27
|
`--base` names the far side of that range and never the commit the comparison runs against directly. The reader resolves the merge base between `HEAD` and the ref, so `--base origin/main` measures what the branch wrote rather than what the trunk gained while the branch was open. Passing the trunk as it stands today is therefore safe on a branch of any age, and a ref sharing no history with `HEAD` refuses as `bad-base`.
|
|
28
28
|
|
package/package.json
CHANGED
package/src/commands/pr.ts
CHANGED
|
@@ -349,15 +349,21 @@ async function listFilesByPage(
|
|
|
349
349
|
/**
|
|
350
350
|
* Reads the body off disk and the changed set from git, which is the shape a
|
|
351
351
|
* fixture and a body still being drafted both need.
|
|
352
|
+
*
|
|
353
|
+
* `cwd` and `root` diverge when a caller passes `--root` to read a pull
|
|
354
|
+
* request against a worktree other than the one they are standing in. The
|
|
355
|
+
* body path is resolved against `cwd`, since it is correct from where the
|
|
356
|
+
* caller stands regardless of which tree `--root` names.
|
|
352
357
|
*/
|
|
353
358
|
async function readFromFile(
|
|
354
359
|
root: string,
|
|
360
|
+
cwd: string,
|
|
355
361
|
path: string,
|
|
356
362
|
base: string | undefined,
|
|
357
363
|
): Promise<SourceRead> {
|
|
358
364
|
let body: string
|
|
359
365
|
try {
|
|
360
|
-
body = await readFile(resolve(
|
|
366
|
+
body = await readFile(resolve(cwd, path), 'utf8')
|
|
361
367
|
} catch {
|
|
362
368
|
return { kind: 'refused', reason: 'unreadable-body' }
|
|
363
369
|
}
|
|
@@ -403,7 +409,7 @@ async function runKeyChanges(
|
|
|
403
409
|
const source =
|
|
404
410
|
opts.body === undefined
|
|
405
411
|
? await readFromApi(root, number)
|
|
406
|
-
: await readFromFile(root, opts.body, opts.base)
|
|
412
|
+
: await readFromFile(root, process.cwd(), opts.body, opts.base)
|
|
407
413
|
|
|
408
414
|
if (source.kind === 'refused') return refuse(source.reason, emitJson, root)
|
|
409
415
|
|