feat: add support for dot ref

This commit is contained in:
Kamran Ahmed
2026-03-18 00:16:45 +00:00
parent 08dae3ce3e
commit 9faed98b19
3 changed files with 11 additions and 2 deletions
+3 -1
View File
@@ -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
```
+6
View File
@@ -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.`));
+2 -1
View File
@@ -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';
}