pi-diff-review 0.1.21 → 0.1.22
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 +8 -0
- package/package.json +1 -1
- package/src/diff/source.ts +10 -1
package/README.md
CHANGED
|
@@ -47,6 +47,14 @@ Review a branch or commit range by passing any `git diff` arguments after `/diff
|
|
|
47
47
|
/diff main...HEAD
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
Review a single file by using a git pathspec after `--`. Pi path autocomplete works here too:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
/diff -- @src/index.ts
|
|
54
|
+
/diff --cached -- @src/index.ts
|
|
55
|
+
/diff main...HEAD -- @src/index.ts
|
|
56
|
+
```
|
|
57
|
+
|
|
50
58
|
`/diff <git-diff-args>` is passed through to `git diff`, so these examples are equivalent to running `git diff`, `git diff --cached`, and `git diff main...HEAD` locally before opening the review UI.
|
|
51
59
|
|
|
52
60
|
Open one or more files or folders with `/view`:
|
package/package.json
CHANGED
package/src/diff/source.ts
CHANGED
|
@@ -22,13 +22,22 @@ export function parseDiffSource(args: string): DiffSource {
|
|
|
22
22
|
|
|
23
23
|
function tokenizeDiffArgs(input: string): string[] {
|
|
24
24
|
try {
|
|
25
|
-
return tokenizeShellArgs(input);
|
|
25
|
+
return normalizeDiffPathspecs(tokenizeShellArgs(input));
|
|
26
26
|
} catch (error) {
|
|
27
27
|
const message = error instanceof Error ? error.message : String(error);
|
|
28
28
|
throw new Error(message.replace(/in arguments$/, "in git diff args"));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function normalizeDiffPathspecs(args: string[]): string[] {
|
|
33
|
+
const separatorIndex = args.indexOf("--");
|
|
34
|
+
if (separatorIndex < 0) return args;
|
|
35
|
+
|
|
36
|
+
return args.map((arg, index) =>
|
|
37
|
+
index > separatorIndex && arg.startsWith("@") ? arg.slice(1) : arg,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
32
41
|
export const DIFF_MAX_BUFFER_BYTES = 128 * 1024 * 1024;
|
|
33
42
|
|
|
34
43
|
export function getDiff(cwd: string, source: DiffSource): string {
|