cherrypick-interactive 1.10.1 → 1.12.0
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/package.json +8 -3
- package/src/tui/App.js +14 -6
- package/src/tui/CommitRow.js +18 -8
- package/src/tui/KeyBar.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cherrypick-interactive",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Interactively cherry-pick commits that are in dev but not in main, using subject-based comparison.",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"bin": "cli.js",
|
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
"check": "biome check .",
|
|
16
16
|
"fix": "biome check --write .",
|
|
17
17
|
"release": "npm publish --access public",
|
|
18
|
-
"test": "node --test test/**/*.test.js"
|
|
18
|
+
"test": "node --test test/**/*.test.js",
|
|
19
|
+
"prepare": "simple-git-hooks"
|
|
20
|
+
},
|
|
21
|
+
"simple-git-hooks": {
|
|
22
|
+
"pre-push": "yarn test"
|
|
19
23
|
},
|
|
20
24
|
"engines": {
|
|
21
25
|
"node": ">=20"
|
|
@@ -33,7 +37,8 @@
|
|
|
33
37
|
"yargs": "^18.0.0"
|
|
34
38
|
},
|
|
35
39
|
"devDependencies": {
|
|
36
|
-
"@biomejs/biome": "^1.9.4"
|
|
40
|
+
"@biomejs/biome": "^1.9.4",
|
|
41
|
+
"simple-git-hooks": "^2.13.1"
|
|
37
42
|
},
|
|
38
43
|
"keywords": [
|
|
39
44
|
"git",
|
package/src/tui/App.js
CHANGED
|
@@ -14,6 +14,7 @@ export function App({ commits, gitRawFn, devBranch, mainBranch, since, onDone })
|
|
|
14
14
|
const [filterText, setFilterText] = useState('');
|
|
15
15
|
const [isSearching, setIsSearching] = useState(false);
|
|
16
16
|
const [searchInput, setSearchInput] = useState('');
|
|
17
|
+
const [showPreview, setShowPreview] = useState(true);
|
|
17
18
|
const [showDiff, setShowDiff] = useState(false);
|
|
18
19
|
const [diffText, setDiffText] = useState('');
|
|
19
20
|
const [confirmQuit, setConfirmQuit] = useState(false);
|
|
@@ -28,7 +29,7 @@ export function App({ commits, gitRawFn, devBranch, mainBranch, since, onDone })
|
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
if (!currentCommit) return;
|
|
30
31
|
let cancelled = false;
|
|
31
|
-
gitRawFn(['show', '--stat', '--format=', currentCommit.hash]).then((text) => {
|
|
32
|
+
gitRawFn(['show', '--stat', '--format=', '--color=always', currentCommit.hash]).then((text) => {
|
|
32
33
|
if (!cancelled) setPreviewText(text.trim());
|
|
33
34
|
}).catch(() => {
|
|
34
35
|
if (!cancelled) setPreviewText('(unable to load preview)');
|
|
@@ -114,7 +115,7 @@ export function App({ commits, gitRawFn, devBranch, mainBranch, since, onDone })
|
|
|
114
115
|
if (currentCommit) {
|
|
115
116
|
setShowDiff(true);
|
|
116
117
|
setDiffText('Loading...');
|
|
117
|
-
gitRawFn(['show', '--stat', '-p', currentCommit.hash]).then((text) => {
|
|
118
|
+
gitRawFn(['show', '--stat', '-p', '--color=always', currentCommit.hash]).then((text) => {
|
|
118
119
|
setDiffText(text.trim());
|
|
119
120
|
}).catch(() => {
|
|
120
121
|
setDiffText('(unable to load diff)');
|
|
@@ -122,6 +123,11 @@ export function App({ commits, gitRawFn, devBranch, mainBranch, since, onDone })
|
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
|
|
126
|
+
// Toggle preview
|
|
127
|
+
else if (input === 'p') {
|
|
128
|
+
setShowPreview((v) => !v);
|
|
129
|
+
}
|
|
130
|
+
|
|
125
131
|
// Confirm
|
|
126
132
|
else if (key.return) {
|
|
127
133
|
const selectedHashes = [...selected];
|
|
@@ -185,10 +191,12 @@ export function App({ commits, gitRawFn, devBranch, mainBranch, since, onDone })
|
|
|
185
191
|
isSearching=${isSearching}
|
|
186
192
|
selectedCount=${selected.size}
|
|
187
193
|
/>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
${showPreview ? html`
|
|
195
|
+
<${Preview}
|
|
196
|
+
previewText=${previewText}
|
|
197
|
+
hash=${currentCommit?.hash}
|
|
198
|
+
/>
|
|
199
|
+
` : null}
|
|
192
200
|
</${Box}>
|
|
193
201
|
`;
|
|
194
202
|
}
|
package/src/tui/CommitRow.js
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import { Text, Box
|
|
1
|
+
import { Text, Box } from 'ink';
|
|
2
2
|
import { html } from './html.js';
|
|
3
3
|
|
|
4
4
|
export function CommitRow({ hash, subject, date, isSelected, isCursor }) {
|
|
5
5
|
const checkbox = isSelected ? '☑' : '☐';
|
|
6
6
|
const checkColor = isSelected ? 'green' : 'gray';
|
|
7
7
|
const cursor = isCursor ? '>' : ' ';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
let subjectColor = 'gray';
|
|
10
|
+
let hashColor = 'dim';
|
|
11
|
+
let dateColor = 'dim';
|
|
12
|
+
if (isCursor) {
|
|
13
|
+
subjectColor = 'white';
|
|
14
|
+
hashColor = 'cyan';
|
|
15
|
+
dateColor = 'gray';
|
|
16
|
+
} else if (isSelected) {
|
|
17
|
+
subjectColor = 'green';
|
|
18
|
+
hashColor = 'green';
|
|
19
|
+
dateColor = 'green';
|
|
20
|
+
}
|
|
10
21
|
|
|
11
22
|
return html`
|
|
12
23
|
<${Box}>
|
|
13
|
-
<${Text} color=${
|
|
24
|
+
<${Text} color=${isCursor ? 'cyan' : undefined}>${cursor} </${Text}>
|
|
14
25
|
<${Text} color=${checkColor}>${checkbox} </${Text}>
|
|
15
|
-
<${Text} color
|
|
16
|
-
<${Text} color=${subjectColor}
|
|
17
|
-
<${
|
|
18
|
-
<${Text} color="dim">${date}</${Text}>
|
|
26
|
+
<${Text} color=${hashColor}>${hash.slice(0, 7)} </${Text}>
|
|
27
|
+
<${Text} color=${subjectColor}>${subject}</${Text}>
|
|
28
|
+
<${Text} color=${dateColor}>${date ? ` (${date})` : ''}</${Text}>
|
|
19
29
|
</${Box}>
|
|
20
30
|
`;
|
|
21
31
|
}
|
package/src/tui/KeyBar.js
CHANGED
|
@@ -13,7 +13,7 @@ export function KeyBar({ isSearching, selectedCount }) {
|
|
|
13
13
|
return html`
|
|
14
14
|
<${Box} paddingX=${1}>
|
|
15
15
|
<${Text} color="dim">
|
|
16
|
-
[space] toggle [a] all [n] none [/] search [d] diff [enter] confirm (${selectedCount}) [q] quit
|
|
16
|
+
[space] toggle [a] all [n] none [/] search [d] diff [p] preview [enter] confirm (${selectedCount}) [q] quit
|
|
17
17
|
</${Text}>
|
|
18
18
|
</${Box}>
|
|
19
19
|
`;
|