mirror of
https://github.com/nilbuild/diffity.git
synced 2026-09-19 07:26:16 +08:00
feat: add support for dot ref
This commit is contained in:
@@ -57,6 +57,7 @@ Opens the diff viewer in your browser. Accepts the same refs as the CLI, plus na
|
||||
|
||||
```
|
||||
/diffity-diff # working tree changes
|
||||
/diffity-diff main # current branch against main
|
||||
/diffity-diff main..feature # branch diff
|
||||
/diffity-diff HEAD~1 # last commit
|
||||
/diffity-diff last 3 commits # natural language works too
|
||||
@@ -70,8 +71,9 @@ Your agent reviews the diff and leaves inline comments in the viewer. Uses sever
|
||||
|
||||
```
|
||||
/diffity-review # review working tree changes
|
||||
/diffity-review main # review what you're merging into main
|
||||
/diffity-review main..feature # review what you're merging into main
|
||||
/diffity-review security # focus on security issues
|
||||
/diffity-review identify security issues # focus on security issues
|
||||
/diffity-review performance in src/lib # focus on performance in specific dir
|
||||
/diffity-review last 3 commits # natural language works too
|
||||
```
|
||||
|
||||
@@ -72,6 +72,12 @@ range syntax (main..feature, main...feature) also work.`)
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < refs.length; i++) {
|
||||
if (refs[i] === '.') {
|
||||
refs[i] = 'work';
|
||||
}
|
||||
}
|
||||
|
||||
for (const ref of refs) {
|
||||
if (!isValidGitRef(ref)) {
|
||||
console.error(pc.red(`Error: '${ref}' is not a valid git reference.`));
|
||||
|
||||
@@ -44,6 +44,7 @@ export function resolveRef(ref: string, extraArgs: string[] = []): string {
|
||||
}
|
||||
return getUntrackedDiff(files);
|
||||
}
|
||||
case '.':
|
||||
case 'work': {
|
||||
let raw = getDiff(['HEAD', ...extraArgs]);
|
||||
const untrackedFiles = getUntrackedFiles();
|
||||
@@ -98,7 +99,7 @@ export function normalizeRef(ref: string): string {
|
||||
}
|
||||
|
||||
export function resolveBaseRef(ref: string): string {
|
||||
if (['staged', 'working', 'work', 'unstaged', 'untracked'].includes(ref)) {
|
||||
if (['staged', 'working', 'work', '.', 'unstaged', 'untracked'].includes(ref)) {
|
||||
return 'HEAD';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user