diffwatch 1.0.5 → 1.0.8
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/dist/index.js +86 -12
- package/dist/index.js.map +1 -1
- package/dist/utils/git.d.ts +1 -0
- package/dist/utils/git.js +30 -8
- package/dist/utils/git.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +481 -403
- package/src/utils/git.ts +28 -9
package/dist/index.js
CHANGED
|
@@ -23,14 +23,14 @@ function main() {
|
|
|
23
23
|
const args = process.argv.slice(2);
|
|
24
24
|
let repoPath = process.cwd();
|
|
25
25
|
const showHelp = () => {
|
|
26
|
-
console.log(`
|
|
27
|
-
Usage: diffwatch [path] [options]
|
|
28
|
-
|
|
29
|
-
Arguments:
|
|
30
|
-
path Path to the git repository (default: current directory)
|
|
31
|
-
|
|
32
|
-
Options:
|
|
33
|
-
-h, --help Show help information
|
|
26
|
+
console.log(`
|
|
27
|
+
Usage: diffwatch [path] [options]
|
|
28
|
+
|
|
29
|
+
Arguments:
|
|
30
|
+
path Path to the git repository (default: current directory)
|
|
31
|
+
|
|
32
|
+
Options:
|
|
33
|
+
-h, --help Show help information
|
|
34
34
|
`);
|
|
35
35
|
process.exit(0);
|
|
36
36
|
};
|
|
@@ -76,8 +76,8 @@ Options:
|
|
|
76
76
|
top: 0,
|
|
77
77
|
left: 0,
|
|
78
78
|
width: '30%',
|
|
79
|
-
height: '
|
|
80
|
-
label: '
|
|
79
|
+
height: '99%',
|
|
80
|
+
label: 'Files (0)',
|
|
81
81
|
keys: true,
|
|
82
82
|
vi: true,
|
|
83
83
|
mouse: true,
|
|
@@ -97,7 +97,7 @@ Options:
|
|
|
97
97
|
top: 0,
|
|
98
98
|
left: '30%',
|
|
99
99
|
width: '70%',
|
|
100
|
-
height: '
|
|
100
|
+
height: '99%',
|
|
101
101
|
label: ' Diff () ',
|
|
102
102
|
keys: true,
|
|
103
103
|
vi: true,
|
|
@@ -133,9 +133,38 @@ Options:
|
|
|
133
133
|
inputOnFocus: true,
|
|
134
134
|
style: { fg: 'white', bg: 'black' },
|
|
135
135
|
});
|
|
136
|
+
// Confirmation dialog for revert
|
|
137
|
+
const confirmDialog = blessed.box({
|
|
138
|
+
top: 'center',
|
|
139
|
+
left: 'center',
|
|
140
|
+
width: '38%',
|
|
141
|
+
label: ' Confirm Revert ',
|
|
142
|
+
height: 3,
|
|
143
|
+
content: 'Press ENTER key to confirm revert or ESC to cancel.',
|
|
144
|
+
border: { type: 'line' },
|
|
145
|
+
style: {
|
|
146
|
+
fg: 'yellow',
|
|
147
|
+
bg: 'black',
|
|
148
|
+
border: { fg: 'yellow' }
|
|
149
|
+
},
|
|
150
|
+
hidden: true,
|
|
151
|
+
});
|
|
152
|
+
// Footer box to show shortcuts - aligned with the panes
|
|
153
|
+
const footer = blessed.box({
|
|
154
|
+
bottom: 0,
|
|
155
|
+
left: 0,
|
|
156
|
+
width: '100%',
|
|
157
|
+
height: 1,
|
|
158
|
+
align: 'center',
|
|
159
|
+
content: chalk_1.default.green('←→') + ' Switch |' + chalk_1.default.green(' ⏎') + ' Open | ' + chalk_1.default.green('S') + ' Search | ' + chalk_1.default.green('R') + ' Revert | ' + chalk_1.default.green('Q') + ' Quit ',
|
|
160
|
+
});
|
|
161
|
+
// Adjust footer to align with the panes
|
|
162
|
+
// Note: We'll adjust this after screen initialization
|
|
136
163
|
screen.append(fileList);
|
|
137
164
|
screen.append(diffView);
|
|
138
165
|
screen.append(searchBox);
|
|
166
|
+
screen.append(confirmDialog);
|
|
167
|
+
screen.append(footer);
|
|
139
168
|
const updateBorders = () => {
|
|
140
169
|
fileList.style.border.fg = screen.focused === fileList ? 'yellow' : 'white';
|
|
141
170
|
diffView.style.border.fg = screen.focused === diffView ? 'yellow' : 'white';
|
|
@@ -281,7 +310,7 @@ Options:
|
|
|
281
310
|
return `${color}${f.path}{/}`;
|
|
282
311
|
});
|
|
283
312
|
fileList.setItems(items);
|
|
284
|
-
const labelTitle = currentSearchTerm ? `
|
|
313
|
+
const labelTitle = currentSearchTerm ? `Files (${files.length}) - Searching: "${currentSearchTerm}"` : `Files (${files.length})`;
|
|
285
314
|
fileList.setLabel(labelTitle);
|
|
286
315
|
if (items.length > 0) {
|
|
287
316
|
// Restore selection by path if possible
|
|
@@ -295,6 +324,8 @@ Options:
|
|
|
295
324
|
yield updateDiff();
|
|
296
325
|
}
|
|
297
326
|
else {
|
|
327
|
+
// Clear the file list when there are no files
|
|
328
|
+
fileList.clearItems();
|
|
298
329
|
diffView.setContent(currentSearchTerm ? `No files match "${currentSearchTerm}".` : 'No changes detected.');
|
|
299
330
|
diffView.setLabel(' Diff () ');
|
|
300
331
|
}
|
|
@@ -321,6 +352,12 @@ Options:
|
|
|
321
352
|
screen.render();
|
|
322
353
|
fileList.focus();
|
|
323
354
|
}
|
|
355
|
+
else if (!confirmDialog.hidden) {
|
|
356
|
+
// Close the confirmation dialog if it's open
|
|
357
|
+
confirmDialog.hide();
|
|
358
|
+
fileList.focus();
|
|
359
|
+
screen.render();
|
|
360
|
+
}
|
|
324
361
|
else {
|
|
325
362
|
screen.destroy();
|
|
326
363
|
process.exit(0);
|
|
@@ -369,6 +406,43 @@ Options:
|
|
|
369
406
|
openInEditor(selectedFile.path);
|
|
370
407
|
}
|
|
371
408
|
});
|
|
409
|
+
// Handle revert key press
|
|
410
|
+
screen.key(['r'], () => __awaiter(this, void 0, void 0, function* () {
|
|
411
|
+
const selectedIndex = fileList.selected;
|
|
412
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
413
|
+
if (selectedFile) {
|
|
414
|
+
confirmDialog.setContent(`Press SPACE key to confirm revert or ESC to cancel.`);
|
|
415
|
+
confirmDialog.show();
|
|
416
|
+
confirmDialog.focus();
|
|
417
|
+
screen.render();
|
|
418
|
+
}
|
|
419
|
+
}));
|
|
420
|
+
// Handle confirmation dialog response with SPACE key
|
|
421
|
+
confirmDialog.key(['space'], () => __awaiter(this, void 0, void 0, function* () {
|
|
422
|
+
confirmDialog.hide();
|
|
423
|
+
const selectedIndex = fileList.selected;
|
|
424
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
425
|
+
if (selectedFile) {
|
|
426
|
+
try {
|
|
427
|
+
yield gitHandler.revertFile(selectedFile.path);
|
|
428
|
+
console.log(chalk_1.default.green(`File ${selectedFile.path} reverted successfully.`));
|
|
429
|
+
// Refresh the file list after reverting
|
|
430
|
+
yield updateFileList();
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
434
|
+
console.error(chalk_1.default.red(`Error reverting file: ${errorMessage}`));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
fileList.focus();
|
|
438
|
+
screen.render();
|
|
439
|
+
}));
|
|
440
|
+
// Handle cancellation with ESC key
|
|
441
|
+
confirmDialog.key(['escape', 'q'], () => {
|
|
442
|
+
confirmDialog.hide();
|
|
443
|
+
fileList.focus();
|
|
444
|
+
screen.render();
|
|
445
|
+
});
|
|
372
446
|
setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
373
447
|
yield updateFileList();
|
|
374
448
|
}), 5000);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC3C,kDAA0B;AAC1B,iDAAsC;AACtC,qCAAqD;AACrD,2DAAiE;AAEjE,SAAe,IAAI;;QACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAE7B,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC;;;;;;;;KAQX,CAAC,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,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AAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/utils/git.d.ts
CHANGED
package/dist/utils/git.js
CHANGED
|
@@ -32,24 +32,35 @@ class GitHandler {
|
|
|
32
32
|
getStatus() {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const status = yield this.git.status();
|
|
35
|
-
const
|
|
35
|
+
const uniqueFiles = new Map();
|
|
36
|
+
// Process each status category and add to map (which prevents duplicates)
|
|
36
37
|
status.modified.forEach(path => {
|
|
37
|
-
|
|
38
|
+
uniqueFiles.set(path, { path, status: 'modified' });
|
|
38
39
|
});
|
|
39
40
|
status.deleted.forEach(path => {
|
|
40
|
-
|
|
41
|
+
// Only add if not already in the map
|
|
42
|
+
if (!uniqueFiles.has(path)) {
|
|
43
|
+
uniqueFiles.set(path, { path, status: 'deleted' });
|
|
44
|
+
}
|
|
41
45
|
});
|
|
42
46
|
status.created.forEach(path => {
|
|
43
|
-
|
|
47
|
+
// Only add if not already in the map
|
|
48
|
+
if (!uniqueFiles.has(path)) {
|
|
49
|
+
uniqueFiles.set(path, { path, status: 'added' });
|
|
50
|
+
}
|
|
44
51
|
});
|
|
45
52
|
status.not_added.forEach(path => {
|
|
46
|
-
|
|
53
|
+
// Only add if not already in the map
|
|
54
|
+
if (!uniqueFiles.has(path)) {
|
|
55
|
+
uniqueFiles.set(path, { path, status: 'unstaged' });
|
|
56
|
+
}
|
|
47
57
|
});
|
|
48
58
|
status.renamed.forEach(r => {
|
|
49
|
-
|
|
59
|
+
// Only add if not already in the map
|
|
60
|
+
if (!uniqueFiles.has(r.to)) {
|
|
61
|
+
uniqueFiles.set(r.to, { path: r.to, status: 'added' });
|
|
62
|
+
}
|
|
50
63
|
});
|
|
51
|
-
const uniqueFiles = new Map();
|
|
52
|
-
files.forEach(f => uniqueFiles.set(f.path, f));
|
|
53
64
|
// Add last modified time for sorting
|
|
54
65
|
const fileArray = Array.from(uniqueFiles.values());
|
|
55
66
|
yield Promise.all(fileArray.map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -158,6 +169,17 @@ class GitHandler {
|
|
|
158
169
|
}
|
|
159
170
|
});
|
|
160
171
|
}
|
|
172
|
+
revertFile(filePath) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
try {
|
|
175
|
+
// Restore the specific file to HEAD version
|
|
176
|
+
yield this.git.raw(['restore', filePath]);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
throw new Error(`Could not revert file: ${error}`);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
161
183
|
}
|
|
162
184
|
exports.GitHandler = GitHandler;
|
|
163
185
|
//# sourceMappingURL=git.js.map
|
package/dist/utils/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgE;AAChE,2DAA6B;AAQ7B,MAAa,UAAU;IAGrB,YAAY,aAAqB,OAAO,CAAC,GAAG,EAAE;QAC5C,IAAI,CAAC,GAAG,GAAG,IAAA,sBAAS,EAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEK,MAAM;;YACV,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;YACtC,CAAC;YAAC,WAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KAAA;IAEK,SAAS;;YACb,MAAM,MAAM,GAAiB,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;YACrD,MAAM,
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgE;AAChE,2DAA6B;AAQ7B,MAAa,UAAU;IAGrB,YAAY,a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CAAC;YACxC,CAAC;QACH,CAAC;KAAA;IAEK,UAAU,CAAC,QAAgB;;YAC/B,IAAI,CAAC;gBACH,4CAA4C;gBAC5C,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC5C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,EAAE,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;KAAA;CACF;AAtKD,gCAsKC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,403 +1,481 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const blessed = require('neo-neo-blessed');
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { spawn } from 'child_process';
|
|
5
|
-
import { GitHandler, FileStatus } from './utils/git';
|
|
6
|
-
import { formatDiffWithDiff2Html } from './utils/diff-formatter';
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
const args = process.argv.slice(2);
|
|
10
|
-
let repoPath = process.cwd();
|
|
11
|
-
|
|
12
|
-
const showHelp = () => {
|
|
13
|
-
console.log(`
|
|
14
|
-
Usage: diffwatch [path] [options]
|
|
15
|
-
|
|
16
|
-
Arguments:
|
|
17
|
-
path Path to the git repository (default: current directory)
|
|
18
|
-
|
|
19
|
-
Options:
|
|
20
|
-
-h, --help Show help information
|
|
21
|
-
`);
|
|
22
|
-
process.exit(0);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const positionalArgs = [];
|
|
26
|
-
for (let i = 0; i < args.length; i++) {
|
|
27
|
-
if (args[i] === '-h' || args[i] === '--help') {
|
|
28
|
-
showHelp();
|
|
29
|
-
} else if (args[i].startsWith('-')) {
|
|
30
|
-
// Ignore unknown flags or handle them if needed
|
|
31
|
-
} else {
|
|
32
|
-
positionalArgs.push(args[i]);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (positionalArgs.length > 0) {
|
|
37
|
-
repoPath = positionalArgs[0];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
process.chdir(repoPath);
|
|
42
|
-
} catch (err) {
|
|
43
|
-
console.error(`Error: Could not change directory to ${repoPath}`);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const gitHandler = new GitHandler(repoPath);
|
|
48
|
-
|
|
49
|
-
if (!(await gitHandler.isRepo())) {
|
|
50
|
-
console.log(chalk.red(`Error: ${repoPath} is not a git repository.`));
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Force xterm-256color to encourage better mouse support on Windows terminals
|
|
55
|
-
if (process.platform === 'win32' && !process.env.TERM) {
|
|
56
|
-
process.env.TERM = 'xterm-256color';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const screen = blessed.screen({
|
|
60
|
-
smartCSR: true,
|
|
61
|
-
title: 'diffwatch',
|
|
62
|
-
mouse: true,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Explicitly enable mouse tracking
|
|
66
|
-
screen.program.enableMouse();
|
|
67
|
-
|
|
68
|
-
const fileList = blessed.list({
|
|
69
|
-
top: 0,
|
|
70
|
-
left: 0,
|
|
71
|
-
width: '30%',
|
|
72
|
-
height: '
|
|
73
|
-
label: '
|
|
74
|
-
keys: true,
|
|
75
|
-
vi: true,
|
|
76
|
-
mouse: true,
|
|
77
|
-
tags: true,
|
|
78
|
-
scrollbar: {
|
|
79
|
-
ch: ' ',
|
|
80
|
-
track: { bg: 'white' },
|
|
81
|
-
style: { bg: 'blue' },
|
|
82
|
-
},
|
|
83
|
-
style: {
|
|
84
|
-
selected: { fg: 'black', bg: 'white' },
|
|
85
|
-
border: { fg: 'white' },
|
|
86
|
-
},
|
|
87
|
-
border: { type: 'line' },
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const diffView = blessed.scrollabletext({
|
|
91
|
-
top: 0,
|
|
92
|
-
left: '30%',
|
|
93
|
-
width: '70%',
|
|
94
|
-
height: '
|
|
95
|
-
label: ' Diff () ',
|
|
96
|
-
keys: true,
|
|
97
|
-
vi: true,
|
|
98
|
-
mouse: true,
|
|
99
|
-
scrollbar: {
|
|
100
|
-
ch: ' ',
|
|
101
|
-
track: { bg: 'white' },
|
|
102
|
-
style: { bg: 'blue' },
|
|
103
|
-
},
|
|
104
|
-
style: {
|
|
105
|
-
border: { fg: 'white' },
|
|
106
|
-
},
|
|
107
|
-
border: { type: 'line' },
|
|
108
|
-
tags: false,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const searchBox = blessed.box({
|
|
112
|
-
top: 'center',
|
|
113
|
-
left: 'center',
|
|
114
|
-
width: '50%',
|
|
115
|
-
height: 3,
|
|
116
|
-
label: ' Search ',
|
|
117
|
-
border: { type: 'line' },
|
|
118
|
-
style: { border: { fg: 'yellow' } },
|
|
119
|
-
hidden: true,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const searchInput = blessed.textbox({
|
|
123
|
-
parent: searchBox,
|
|
124
|
-
top: 0,
|
|
125
|
-
left: 0,
|
|
126
|
-
width: '100%-2',
|
|
127
|
-
height: 1,
|
|
128
|
-
keys: true,
|
|
129
|
-
inputOnFocus: true,
|
|
130
|
-
style: { fg: 'white', bg: 'black' },
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
await
|
|
304
|
-
} else {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
} else {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const blessed = require('neo-neo-blessed');
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import { GitHandler, FileStatus } from './utils/git';
|
|
6
|
+
import { formatDiffWithDiff2Html } from './utils/diff-formatter';
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
let repoPath = process.cwd();
|
|
11
|
+
|
|
12
|
+
const showHelp = () => {
|
|
13
|
+
console.log(`
|
|
14
|
+
Usage: diffwatch [path] [options]
|
|
15
|
+
|
|
16
|
+
Arguments:
|
|
17
|
+
path Path to the git repository (default: current directory)
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
-h, --help Show help information
|
|
21
|
+
`);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const positionalArgs = [];
|
|
26
|
+
for (let i = 0; i < args.length; i++) {
|
|
27
|
+
if (args[i] === '-h' || args[i] === '--help') {
|
|
28
|
+
showHelp();
|
|
29
|
+
} else if (args[i].startsWith('-')) {
|
|
30
|
+
// Ignore unknown flags or handle them if needed
|
|
31
|
+
} else {
|
|
32
|
+
positionalArgs.push(args[i]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (positionalArgs.length > 0) {
|
|
37
|
+
repoPath = positionalArgs[0];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
process.chdir(repoPath);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error(`Error: Could not change directory to ${repoPath}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const gitHandler = new GitHandler(repoPath);
|
|
48
|
+
|
|
49
|
+
if (!(await gitHandler.isRepo())) {
|
|
50
|
+
console.log(chalk.red(`Error: ${repoPath} is not a git repository.`));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Force xterm-256color to encourage better mouse support on Windows terminals
|
|
55
|
+
if (process.platform === 'win32' && !process.env.TERM) {
|
|
56
|
+
process.env.TERM = 'xterm-256color';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const screen = blessed.screen({
|
|
60
|
+
smartCSR: true,
|
|
61
|
+
title: 'diffwatch',
|
|
62
|
+
mouse: true,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Explicitly enable mouse tracking
|
|
66
|
+
screen.program.enableMouse();
|
|
67
|
+
|
|
68
|
+
const fileList = blessed.list({
|
|
69
|
+
top: 0,
|
|
70
|
+
left: 0,
|
|
71
|
+
width: '30%',
|
|
72
|
+
height: '99%',
|
|
73
|
+
label: 'Files (0)',
|
|
74
|
+
keys: true,
|
|
75
|
+
vi: true,
|
|
76
|
+
mouse: true,
|
|
77
|
+
tags: true,
|
|
78
|
+
scrollbar: {
|
|
79
|
+
ch: ' ',
|
|
80
|
+
track: { bg: 'white' },
|
|
81
|
+
style: { bg: 'blue' },
|
|
82
|
+
},
|
|
83
|
+
style: {
|
|
84
|
+
selected: { fg: 'black', bg: 'white' },
|
|
85
|
+
border: { fg: 'white' },
|
|
86
|
+
},
|
|
87
|
+
border: { type: 'line' },
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const diffView = blessed.scrollabletext({
|
|
91
|
+
top: 0,
|
|
92
|
+
left: '30%',
|
|
93
|
+
width: '70%',
|
|
94
|
+
height: '99%',
|
|
95
|
+
label: ' Diff () ',
|
|
96
|
+
keys: true,
|
|
97
|
+
vi: true,
|
|
98
|
+
mouse: true,
|
|
99
|
+
scrollbar: {
|
|
100
|
+
ch: ' ',
|
|
101
|
+
track: { bg: 'white' },
|
|
102
|
+
style: { bg: 'blue' },
|
|
103
|
+
},
|
|
104
|
+
style: {
|
|
105
|
+
border: { fg: 'white' },
|
|
106
|
+
},
|
|
107
|
+
border: { type: 'line' },
|
|
108
|
+
tags: false,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const searchBox = blessed.box({
|
|
112
|
+
top: 'center',
|
|
113
|
+
left: 'center',
|
|
114
|
+
width: '50%',
|
|
115
|
+
height: 3,
|
|
116
|
+
label: ' Search ',
|
|
117
|
+
border: { type: 'line' },
|
|
118
|
+
style: { border: { fg: 'yellow' } },
|
|
119
|
+
hidden: true,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const searchInput = blessed.textbox({
|
|
123
|
+
parent: searchBox,
|
|
124
|
+
top: 0,
|
|
125
|
+
left: 0,
|
|
126
|
+
width: '100%-2',
|
|
127
|
+
height: 1,
|
|
128
|
+
keys: true,
|
|
129
|
+
inputOnFocus: true,
|
|
130
|
+
style: { fg: 'white', bg: 'black' },
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Confirmation dialog for revert
|
|
134
|
+
const confirmDialog = blessed.box({
|
|
135
|
+
top: 'center',
|
|
136
|
+
left: 'center',
|
|
137
|
+
width: '38%',
|
|
138
|
+
label: ' Confirm Revert ',
|
|
139
|
+
height: 3,
|
|
140
|
+
content: 'Press ENTER key to confirm revert or ESC to cancel.',
|
|
141
|
+
border: { type: 'line' },
|
|
142
|
+
style: {
|
|
143
|
+
fg: 'yellow',
|
|
144
|
+
bg: 'black',
|
|
145
|
+
border: { fg: 'yellow' }
|
|
146
|
+
},
|
|
147
|
+
hidden: true,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Footer box to show shortcuts - aligned with the panes
|
|
151
|
+
const footer = blessed.box({
|
|
152
|
+
bottom: 0,
|
|
153
|
+
left: 0,
|
|
154
|
+
width: '100%',
|
|
155
|
+
height: 1,
|
|
156
|
+
align: 'center',
|
|
157
|
+
content: chalk.green('←→') + ' Switch |' + chalk.green(' ⏎') + ' Open | ' + chalk.green('S') + ' Search | ' + chalk.green('R') + ' Revert | ' + chalk.green('Q') + ' Quit ',
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Adjust footer to align with the panes
|
|
161
|
+
// Note: We'll adjust this after screen initialization
|
|
162
|
+
|
|
163
|
+
screen.append(fileList);
|
|
164
|
+
screen.append(diffView);
|
|
165
|
+
screen.append(searchBox);
|
|
166
|
+
screen.append(confirmDialog);
|
|
167
|
+
screen.append(footer);
|
|
168
|
+
|
|
169
|
+
const updateBorders = () => {
|
|
170
|
+
fileList.style.border.fg = screen.focused === fileList ? 'yellow' : 'white';
|
|
171
|
+
diffView.style.border.fg = screen.focused === diffView ? 'yellow' : 'white';
|
|
172
|
+
screen.render();
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
let currentFiles: FileStatus[] = [];
|
|
176
|
+
let lastSelectedPath: string | null = null;
|
|
177
|
+
let diffUpdateTimeout: NodeJS.Timeout | null = null;
|
|
178
|
+
let currentSearchTerm: string = '';
|
|
179
|
+
|
|
180
|
+
const scheduleDiffUpdate = () => {
|
|
181
|
+
if (diffUpdateTimeout) clearTimeout(diffUpdateTimeout);
|
|
182
|
+
diffUpdateTimeout = setTimeout(async () => {
|
|
183
|
+
await updateDiff();
|
|
184
|
+
}, 150); // 150ms debounce
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const handleScroll = (direction: 'up' | 'down') => {
|
|
188
|
+
if (screen.focused === fileList) {
|
|
189
|
+
if (direction === 'up') {
|
|
190
|
+
fileList.up(1);
|
|
191
|
+
} else {
|
|
192
|
+
fileList.down(1);
|
|
193
|
+
}
|
|
194
|
+
scheduleDiffUpdate();
|
|
195
|
+
screen.render();
|
|
196
|
+
} else if (screen.focused === diffView) {
|
|
197
|
+
const scrollAmount = direction === 'up' ? -2 : 2;
|
|
198
|
+
diffView.scroll(scrollAmount);
|
|
199
|
+
screen.render();
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Remove default wheel listeners to enforce "scroll focused only" behavior
|
|
204
|
+
fileList.removeAllListeners('wheeldown');
|
|
205
|
+
fileList.removeAllListeners('wheelup');
|
|
206
|
+
diffView.removeAllListeners('wheeldown');
|
|
207
|
+
diffView.removeAllListeners('wheelup');
|
|
208
|
+
|
|
209
|
+
// Attach custom scroll handlers to widgets (captures wheel even if hovering specific widget)
|
|
210
|
+
// We use widget-level listeners now that screen.mouse is true.
|
|
211
|
+
// We attach to both to ensure the event is caught regardless of where the mouse is.
|
|
212
|
+
// The handleScroll function will then decide WHAT to scroll based on focus.
|
|
213
|
+
|
|
214
|
+
fileList.on('wheeldown', () => handleScroll('down'));
|
|
215
|
+
fileList.on('wheelup', () => handleScroll('up'));
|
|
216
|
+
|
|
217
|
+
diffView.on('wheeldown', () => handleScroll('down'));
|
|
218
|
+
diffView.on('wheelup', () => handleScroll('up'));
|
|
219
|
+
|
|
220
|
+
// Also listen on screen for events that might miss the widgets (margins, borders)
|
|
221
|
+
screen.on('wheeldown', () => handleScroll('down'));
|
|
222
|
+
screen.on('wheelup', () => handleScroll('up'));
|
|
223
|
+
|
|
224
|
+
const openInEditor = (filePath: string) => {
|
|
225
|
+
try {
|
|
226
|
+
if (process.platform === 'win32') {
|
|
227
|
+
// On Windows, use 'start' to open with default program
|
|
228
|
+
spawn('cmd', ['/c', 'start', '', filePath], { stdio: 'ignore', detached: true }).unref();
|
|
229
|
+
} else {
|
|
230
|
+
// On Unix-like systems, try EDITOR, fallback to xdg-open
|
|
231
|
+
const editor = process.env.EDITOR || process.env.VISUAL || 'xdg-open';
|
|
232
|
+
spawn(editor, [filePath], { stdio: 'ignore', detached: true }).unref();
|
|
233
|
+
}
|
|
234
|
+
} catch (error) {
|
|
235
|
+
console.error(`Failed to open ${filePath}: ${error}`);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const updateDiff = async () => {
|
|
240
|
+
const selectedIndex = fileList.selected;
|
|
241
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
242
|
+
if (selectedFile) {
|
|
243
|
+
let content = '';
|
|
244
|
+
let label = ` Diff (${selectedFile.path}) `;
|
|
245
|
+
|
|
246
|
+
if (selectedFile.status !== 'unchanged' && selectedFile.status !== 'deleted') {
|
|
247
|
+
const diff = await gitHandler.getDiff(selectedFile.path);
|
|
248
|
+
content = formatDiffWithDiff2Html(diff, currentSearchTerm);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (!content && selectedFile.status !== 'deleted') {
|
|
252
|
+
content = await gitHandler.getFileContent(selectedFile.path);
|
|
253
|
+
// Highlight search term in full content
|
|
254
|
+
if (currentSearchTerm) {
|
|
255
|
+
const regex = new RegExp(`(${currentSearchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi');
|
|
256
|
+
content = content.replace(regex, `\x1b[43m\x1b[30m$1\x1b[0m`);
|
|
257
|
+
}
|
|
258
|
+
label = ` File (${selectedFile.path}) `;
|
|
259
|
+
} else if (!content && selectedFile.status === 'deleted') {
|
|
260
|
+
content = chalk.red('File was deleted.');
|
|
261
|
+
label = ` Diff (${selectedFile.path}) `;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const currentContent = diffView.content;
|
|
265
|
+
const currentLabel = diffView.label;
|
|
266
|
+
|
|
267
|
+
// Only update if content or label changed to reduce flickering
|
|
268
|
+
if (content !== currentContent || label !== currentLabel) {
|
|
269
|
+
const savedScroll = diffView.scrollTop;
|
|
270
|
+
const isNewFile = selectedFile.path !== lastSelectedPath;
|
|
271
|
+
|
|
272
|
+
diffView.setContent(content);
|
|
273
|
+
diffView.setLabel(label);
|
|
274
|
+
|
|
275
|
+
if (isNewFile) {
|
|
276
|
+
diffView.scrollTo(0);
|
|
277
|
+
} else {
|
|
278
|
+
diffView.scrollTop = savedScroll;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
lastSelectedPath = selectedFile.path;
|
|
282
|
+
} else {
|
|
283
|
+
const newContent = 'Select a file to view diff.';
|
|
284
|
+
const newLabel = ' Diff () ';
|
|
285
|
+
if (diffView.content !== newContent || diffView.label !== newLabel) {
|
|
286
|
+
diffView.setContent(newContent);
|
|
287
|
+
diffView.setLabel(newLabel);
|
|
288
|
+
diffView.scrollTo(0);
|
|
289
|
+
}
|
|
290
|
+
lastSelectedPath = null;
|
|
291
|
+
}
|
|
292
|
+
screen.render();
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const updateFileList = async () => {
|
|
296
|
+
// Preserve selected file path and scroll positions
|
|
297
|
+
const selectedPath = currentFiles[fileList.selected]?.path;
|
|
298
|
+
const diffScroll = diffView.scrollTop;
|
|
299
|
+
|
|
300
|
+
let files: FileStatus[];
|
|
301
|
+
|
|
302
|
+
if (currentSearchTerm) {
|
|
303
|
+
files = await gitHandler.searchFiles(currentSearchTerm);
|
|
304
|
+
} else {
|
|
305
|
+
files = await gitHandler.getStatus();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
currentFiles = files;
|
|
309
|
+
|
|
310
|
+
const items = files.map(f => {
|
|
311
|
+
let color = '{white-fg}';
|
|
312
|
+
if (f.status === 'added') color = '{green-fg}';
|
|
313
|
+
else if (f.status === 'deleted') color = '{red-fg}';
|
|
314
|
+
else if (f.status === 'modified') color = '{blue-fg}';
|
|
315
|
+
else if (f.status === 'unstaged') color = '{white-fg}';
|
|
316
|
+
else if (f.status === 'unchanged') color = '{grey-fg}';
|
|
317
|
+
|
|
318
|
+
return `${color}${f.path}{/}`;
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
fileList.setItems(items);
|
|
322
|
+
|
|
323
|
+
const labelTitle = currentSearchTerm ? `Files (${files.length}) - Searching: "${currentSearchTerm}"` : `Files (${files.length})`;
|
|
324
|
+
fileList.setLabel(labelTitle);
|
|
325
|
+
|
|
326
|
+
if (items.length > 0) {
|
|
327
|
+
// Restore selection by path if possible
|
|
328
|
+
const newSelectedIndex = selectedPath ? currentFiles.findIndex(f => f.path === selectedPath) : -1;
|
|
329
|
+
fileList.select(newSelectedIndex >= 0 ? newSelectedIndex : 0);
|
|
330
|
+
// Cancel any pending diff update and update immediately
|
|
331
|
+
if (diffUpdateTimeout) {
|
|
332
|
+
clearTimeout(diffUpdateTimeout);
|
|
333
|
+
diffUpdateTimeout = null;
|
|
334
|
+
}
|
|
335
|
+
await updateDiff();
|
|
336
|
+
} else {
|
|
337
|
+
// Clear the file list when there are no files
|
|
338
|
+
fileList.clearItems();
|
|
339
|
+
diffView.setContent(currentSearchTerm ? `No files match "${currentSearchTerm}".` : 'No changes detected.');
|
|
340
|
+
diffView.setLabel(' Diff () ');
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Restore scroll positions if reasonably possible (reset if list changed drastically)
|
|
344
|
+
// Actually, if we filter, the scroll position might be invalid.
|
|
345
|
+
// Ideally we keep it 0 if it was 0 or just let the select() call handle scrolling to the item.
|
|
346
|
+
// The previous implementation blindly restored scrollTop.
|
|
347
|
+
// If the list shrunk, select() should have brought it into view.
|
|
348
|
+
// We only explicitly restore if items.length > 0
|
|
349
|
+
// But setting scroll to previous value might be wrong if the list is now shorter.
|
|
350
|
+
// Safe to only restore diffView scroll as it depends on content, fileList is handled by select.
|
|
351
|
+
|
|
352
|
+
diffView.scrollTop = diffScroll;
|
|
353
|
+
|
|
354
|
+
screen.render();
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
fileList.on('select item', () => {
|
|
358
|
+
scheduleDiffUpdate();
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
fileList.key(['up', 'down'], () => {
|
|
362
|
+
scheduleDiffUpdate();
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
screen.key(['escape', 'q', 'C-c'], () => {
|
|
366
|
+
if (!searchBox.hidden) {
|
|
367
|
+
searchBox.hide();
|
|
368
|
+
screen.render();
|
|
369
|
+
fileList.focus();
|
|
370
|
+
} else if (!confirmDialog.hidden) {
|
|
371
|
+
// Close the confirmation dialog if it's open
|
|
372
|
+
confirmDialog.hide();
|
|
373
|
+
fileList.focus();
|
|
374
|
+
screen.render();
|
|
375
|
+
} else {
|
|
376
|
+
screen.destroy();
|
|
377
|
+
process.exit(0);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
screen.key(['s'], () => {
|
|
382
|
+
searchBox.show();
|
|
383
|
+
searchBox.setFront();
|
|
384
|
+
searchInput.setValue(currentSearchTerm);
|
|
385
|
+
searchInput.focus();
|
|
386
|
+
screen.render();
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
searchInput.on('submit', async (value: string) => {
|
|
390
|
+
currentSearchTerm = (value || '').trim();
|
|
391
|
+
searchBox.hide();
|
|
392
|
+
fileList.focus();
|
|
393
|
+
// Force immediate update
|
|
394
|
+
await updateFileList();
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
searchInput.on('cancel', () => {
|
|
398
|
+
searchBox.hide();
|
|
399
|
+
fileList.focus();
|
|
400
|
+
screen.render();
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
screen.key(['tab'], () => {
|
|
404
|
+
if (screen.focused === fileList) {
|
|
405
|
+
diffView.focus();
|
|
406
|
+
} else {
|
|
407
|
+
fileList.focus();
|
|
408
|
+
}
|
|
409
|
+
updateBorders();
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
screen.key(['left'], () => {
|
|
413
|
+
fileList.focus();
|
|
414
|
+
updateBorders();
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
screen.key(['right'], () => {
|
|
418
|
+
diffView.focus();
|
|
419
|
+
updateBorders();
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
screen.key(['enter'], () => {
|
|
423
|
+
const selectedIndex = fileList.selected;
|
|
424
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
425
|
+
if (selectedFile) {
|
|
426
|
+
openInEditor(selectedFile.path);
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// Handle revert key press
|
|
431
|
+
screen.key(['r'], async () => {
|
|
432
|
+
const selectedIndex = fileList.selected;
|
|
433
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
434
|
+
if (selectedFile) {
|
|
435
|
+
confirmDialog.setContent(`Press SPACE key to confirm revert or ESC to cancel.`);
|
|
436
|
+
confirmDialog.show();
|
|
437
|
+
confirmDialog.focus();
|
|
438
|
+
screen.render();
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
// Handle confirmation dialog response with SPACE key
|
|
443
|
+
confirmDialog.key(['space'], async () => {
|
|
444
|
+
confirmDialog.hide();
|
|
445
|
+
const selectedIndex = fileList.selected;
|
|
446
|
+
const selectedFile = currentFiles[selectedIndex];
|
|
447
|
+
if (selectedFile) {
|
|
448
|
+
try {
|
|
449
|
+
await gitHandler.revertFile(selectedFile.path);
|
|
450
|
+
console.log(chalk.green(`File ${selectedFile.path} reverted successfully.`));
|
|
451
|
+
// Refresh the file list after reverting
|
|
452
|
+
await updateFileList();
|
|
453
|
+
} catch (error) {
|
|
454
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
455
|
+
console.error(chalk.red(`Error reverting file: ${errorMessage}`));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
fileList.focus();
|
|
459
|
+
screen.render();
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
// Handle cancellation with ESC key
|
|
463
|
+
confirmDialog.key(['escape', 'q'], () => {
|
|
464
|
+
confirmDialog.hide();
|
|
465
|
+
fileList.focus();
|
|
466
|
+
screen.render();
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
setInterval(async () => {
|
|
470
|
+
await updateFileList();
|
|
471
|
+
}, 5000);
|
|
472
|
+
|
|
473
|
+
await updateFileList();
|
|
474
|
+
fileList.focus();
|
|
475
|
+
updateBorders();
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
main().catch(err => {
|
|
479
|
+
console.error(err);
|
|
480
|
+
process.exit(1);
|
|
481
|
+
});
|
package/src/utils/git.ts
CHANGED
|
@@ -24,31 +24,41 @@ export class GitHandler {
|
|
|
24
24
|
|
|
25
25
|
async getStatus(): Promise<FileStatus[]> {
|
|
26
26
|
const status: StatusResult = await this.git.status();
|
|
27
|
-
const
|
|
27
|
+
const uniqueFiles = new Map<string, FileStatus>();
|
|
28
28
|
|
|
29
|
+
// Process each status category and add to map (which prevents duplicates)
|
|
29
30
|
status.modified.forEach(path => {
|
|
30
|
-
|
|
31
|
+
uniqueFiles.set(path, { path, status: 'modified' });
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
status.deleted.forEach(path => {
|
|
34
|
-
|
|
35
|
+
// Only add if not already in the map
|
|
36
|
+
if (!uniqueFiles.has(path)) {
|
|
37
|
+
uniqueFiles.set(path, { path, status: 'deleted' });
|
|
38
|
+
}
|
|
35
39
|
});
|
|
36
40
|
|
|
37
41
|
status.created.forEach(path => {
|
|
38
|
-
|
|
42
|
+
// Only add if not already in the map
|
|
43
|
+
if (!uniqueFiles.has(path)) {
|
|
44
|
+
uniqueFiles.set(path, { path, status: 'added' });
|
|
45
|
+
}
|
|
39
46
|
});
|
|
40
47
|
|
|
41
48
|
status.not_added.forEach(path => {
|
|
42
|
-
|
|
49
|
+
// Only add if not already in the map
|
|
50
|
+
if (!uniqueFiles.has(path)) {
|
|
51
|
+
uniqueFiles.set(path, { path, status: 'unstaged' });
|
|
52
|
+
}
|
|
43
53
|
});
|
|
44
54
|
|
|
45
55
|
status.renamed.forEach(r => {
|
|
46
|
-
|
|
56
|
+
// Only add if not already in the map
|
|
57
|
+
if (!uniqueFiles.has(r.to)) {
|
|
58
|
+
uniqueFiles.set(r.to, { path: r.to, status: 'added' });
|
|
59
|
+
}
|
|
47
60
|
});
|
|
48
61
|
|
|
49
|
-
const uniqueFiles = new Map<string, FileStatus>();
|
|
50
|
-
files.forEach(f => uniqueFiles.set(f.path, f));
|
|
51
|
-
|
|
52
62
|
// Add last modified time for sorting
|
|
53
63
|
const fileArray = Array.from(uniqueFiles.values());
|
|
54
64
|
await Promise.all(fileArray.map(async (f) => {
|
|
@@ -154,4 +164,13 @@ export class GitHandler {
|
|
|
154
164
|
return `Error reading file: ${error}`;
|
|
155
165
|
}
|
|
156
166
|
}
|
|
167
|
+
|
|
168
|
+
async revertFile(filePath: string): Promise<void> {
|
|
169
|
+
try {
|
|
170
|
+
// Restore the specific file to HEAD version
|
|
171
|
+
await this.git.raw(['restore', filePath]);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
throw new Error(`Could not revert file: ${error}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
157
176
|
}
|