reslop 0.2.5 → 0.2.7
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/CHANGELOG.md +22 -1
- package/LICENSE +1 -1
- package/README.md +11 -11
- package/bin/reslop.js +3 -8
- package/lib/ansi.js +72 -19
- package/lib/api.js +1 -1
- package/lib/capabilities.js +8 -8
- package/lib/cli.js +61 -75
- package/lib/clipboard.js +39 -47
- package/lib/dashboard/git.js +128 -0
- package/lib/dashboard/model.js +357 -0
- package/lib/dashboard/npm.js +290 -0
- package/lib/dashboard/tree.js +278 -0
- package/lib/deps-diff.js +197 -402
- package/lib/deps.js +113 -240
- package/lib/detect.js +8 -18
- package/lib/diff/align.js +41 -113
- package/lib/diff/diff.js +12 -43
- package/lib/diff/display.js +25 -36
- package/lib/diff/edit.js +6 -20
- package/lib/diff/inline.js +76 -144
- package/lib/diff/items.js +33 -47
- package/lib/diff/parse.js +28 -56
- package/lib/diff/patch.js +12 -33
- package/lib/diff/unit.js +79 -178
- package/lib/editor.js +52 -69
- package/lib/files.js +79 -91
- package/lib/find.js +61 -0
- package/lib/git-branches.js +254 -416
- package/lib/git-deps.js +148 -272
- package/lib/git-reword-todo.js +5 -13
- package/lib/git-worktree.js +161 -214
- package/lib/git.js +21 -49
- package/lib/github.js +67 -181
- package/lib/gitlab.js +40 -90
- package/lib/highlight/bash.js +55 -177
- package/lib/highlight/core.js +155 -141
- package/lib/highlight/css.js +25 -58
- package/lib/highlight/csv.js +19 -37
- package/lib/highlight/dart.js +72 -213
- package/lib/highlight/dot.js +14 -14
- package/lib/highlight/html.js +42 -63
- package/lib/highlight/js.js +177 -506
- package/lib/highlight/json.js +17 -37
- package/lib/highlight/log.js +19 -25
- package/lib/highlight/txt.js +7 -10
- package/lib/highlight.js +17 -46
- package/lib/keys.js +75 -83
- package/lib/manifest.js +67 -126
- package/lib/npm-commands.js +120 -169
- package/lib/remote.js +140 -190
- package/lib/render/branches.js +63 -61
- package/lib/render/chrome.js +412 -347
- package/lib/render/commits.js +160 -361
- package/lib/render/dash-activity.js +212 -0
- package/lib/render/dash-blocks.js +496 -0
- package/lib/render/dash-table.js +295 -0
- package/lib/render/dashboard.js +62 -0
- package/lib/render/diff.js +123 -258
- package/lib/render/files.js +60 -86
- package/lib/render/frame.js +82 -117
- package/lib/render/notes.js +150 -210
- package/lib/render/npm.js +213 -177
- package/lib/render/packages.js +93 -0
- package/lib/render/present.js +4 -11
- package/lib/render/primitives.js +77 -172
- package/lib/render/render.js +5 -14
- package/lib/render/report.js +43 -0
- package/lib/render/repos.js +226 -0
- package/lib/render/search.js +25 -0
- package/lib/render/tiles.js +355 -0
- package/lib/render/unit.js +15 -31
- package/lib/report-model.js +110 -33
- package/lib/report-parse.js +56 -37
- package/lib/report-render.js +102 -59
- package/lib/report-run.js +87 -77
- package/lib/report-test.js +221 -99
- package/lib/report-tools.js +96 -154
- package/lib/review-merge.js +33 -41
- package/lib/review.js +69 -129
- package/lib/runs.js +225 -0
- package/lib/select.js +53 -91
- package/lib/session/accessors.js +14 -21
- package/lib/session/actions.js +189 -65
- package/lib/session/branches.js +164 -222
- package/lib/session/change-actions.js +49 -119
- package/lib/session/commit.js +298 -352
- package/lib/session/compose.js +572 -715
- package/lib/session/dashboard.js +530 -0
- package/lib/session/dispatch.js +197 -171
- package/lib/session/files-pane.js +92 -45
- package/lib/session/find.js +94 -0
- package/lib/session/items.js +6 -17
- package/lib/session/lifecycle.js +420 -466
- package/lib/session/load.js +1 -14
- package/lib/session/navigation.js +4 -2
- package/lib/session/npm.js +403 -420
- package/lib/session/ops.js +5 -13
- package/lib/session/packages.js +143 -0
- package/lib/session/pointer.js +30 -14
- package/lib/session/progress.js +39 -30
- package/lib/session/review.js +1 -3
- package/lib/session/tasks.js +277 -236
- package/lib/session/templates.js +51 -59
- package/lib/session/terminal.js +85 -132
- package/lib/session/view.js +59 -80
- package/lib/session/watch.js +201 -212
- package/lib/session/workspace.js +455 -0
- package/lib/session.js +95 -161
- package/lib/update.js +44 -111
- package/lib/utilities.js +46 -88
- package/lib/workspace.js +166 -0
- package/lib/wrap.js +29 -55
- package/package.json +1 -1
package/lib/session/commit.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const accessors = require('./accessors.js');
|
|
4
|
-
const { stateView } = accessors;
|
|
5
|
-
|
|
6
3
|
const files = require('../files.js');
|
|
7
4
|
const { isReadOnlyOrigin } = files;
|
|
8
5
|
const actions = require('./actions.js');
|
|
@@ -37,10 +34,6 @@ const PENDING_COMMIT = {
|
|
|
37
34
|
|
|
38
35
|
const listedCommits = (commits) => [PENDING_COMMIT].concat(commits ?? []);
|
|
39
36
|
|
|
40
|
-
const isPending = (entry) => Boolean(entry && entry.pending);
|
|
41
|
-
|
|
42
|
-
const briefCommit = (ui) => ui.commits.commitView !== 'full';
|
|
43
|
-
|
|
44
37
|
const joinMessage = (line, rest) => (rest ? `${line}\n${rest}` : line);
|
|
45
38
|
|
|
46
39
|
const tidyCommitMessage = (message) => {
|
|
@@ -50,402 +43,355 @@ const tidyCommitMessage = (message) => {
|
|
|
50
43
|
return lines.join('\n');
|
|
51
44
|
};
|
|
52
45
|
|
|
53
|
-
const keepBriefBody = (ui, text) => {
|
|
54
|
-
if (!briefCommit(ui)) return text;
|
|
55
|
-
const parts = splitMessage(text);
|
|
56
|
-
ui.composer.state.commitBody = parts.rest;
|
|
57
|
-
return parts.line;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
46
|
const fixupMessage = (entry) => {
|
|
61
47
|
const subject = commitLine(entry).trim();
|
|
62
48
|
if (!subject) return 'fixup!';
|
|
63
49
|
return `fixup! ${subject}`;
|
|
64
50
|
};
|
|
65
51
|
|
|
66
|
-
const canCommit = (ui) => {
|
|
67
|
-
const caps = ui.capabilities;
|
|
68
|
-
if (!caps.branches) {
|
|
69
|
-
ui.status = 'read only';
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
for (const item of ui.items) {
|
|
73
|
-
if (isReadOnlyOrigin(item.origin)) {
|
|
74
|
-
ui.status = 'read only';
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
52
|
const hasStagedChanges = (ui) => {
|
|
82
53
|
const repo = ui.repo;
|
|
83
54
|
if (repo.hasStaged) return repo.hasStaged(ui.top);
|
|
84
|
-
|
|
85
|
-
if (item.origin === 'staged') return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
55
|
+
return ui.items.some((item) => item.origin === 'staged');
|
|
88
56
|
};
|
|
89
57
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
58
|
+
class CommitController {
|
|
59
|
+
constructor(ui) {
|
|
60
|
+
this.ui = ui;
|
|
61
|
+
this.reset();
|
|
62
|
+
}
|
|
94
63
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
64
|
+
reset() {
|
|
65
|
+
this.commits = [];
|
|
66
|
+
this.dropName = '';
|
|
67
|
+
this.dropSha = '';
|
|
68
|
+
this.commitView = 'brief';
|
|
69
|
+
}
|
|
100
70
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (hasStagedChanges(ui)) return 0;
|
|
104
|
-
const list = listedCommits(api.state.commits);
|
|
105
|
-
const want = `${ui.rev ?? ''}`;
|
|
106
|
-
const short = `${ui.revShort ?? ''}`;
|
|
107
|
-
if (!want && !short) return 0;
|
|
108
|
-
for (let i = 0; i < list.length; i++) {
|
|
109
|
-
const entry = list[i];
|
|
110
|
-
if (!entry || entry.pending) continue;
|
|
111
|
-
const sha = `${entry.sha ?? ''}`;
|
|
112
|
-
const brief = `${entry.shortSha ?? ''}`;
|
|
113
|
-
if (want && sha === want) return i;
|
|
114
|
-
if (short && (brief === short || sha.startsWith(short))) return i;
|
|
71
|
+
get brief() {
|
|
72
|
+
return this.commitView !== 'full';
|
|
115
73
|
}
|
|
116
|
-
return 0;
|
|
117
|
-
};
|
|
118
74
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return;
|
|
75
|
+
canCommit() {
|
|
76
|
+
const ui = this.ui;
|
|
77
|
+
const readOnly =
|
|
78
|
+
!ui.capabilities.branches ||
|
|
79
|
+
ui.items.some((item) => isReadOnlyOrigin(item.origin));
|
|
80
|
+
if (readOnly) ui.status = 'read only';
|
|
81
|
+
return !readOnly;
|
|
127
82
|
}
|
|
128
|
-
clampCommitCursor(api);
|
|
129
|
-
};
|
|
130
83
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
84
|
+
canWrite() {
|
|
85
|
+
return this.ui.nav.pane === 'commits' && this.canCommit();
|
|
86
|
+
}
|
|
135
87
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const repo = api.ui.repo;
|
|
139
|
-
if (!repo.listCommits) {
|
|
140
|
-
api.ui.status = 'read only';
|
|
141
|
-
return;
|
|
88
|
+
selected() {
|
|
89
|
+
return listedCommits(this.commits)[this.ui.nav.commitCursor] ?? null;
|
|
142
90
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
91
|
+
|
|
92
|
+
loadCommits() {
|
|
93
|
+
const ui = this.ui;
|
|
94
|
+
try {
|
|
95
|
+
this.commits = ui.repo.listCommits(ui.top);
|
|
96
|
+
return true;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
ui.status = error.message;
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
148
101
|
}
|
|
149
|
-
const nav = api.ui.nav;
|
|
150
|
-
nav.commitCursor = commitIndexForView(api);
|
|
151
|
-
nav.pane = 'commits';
|
|
152
|
-
nav.resetListScroll('commits');
|
|
153
|
-
api.ui.status = '';
|
|
154
|
-
nav.clearSelection();
|
|
155
|
-
};
|
|
156
102
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
);
|
|
164
|
-
if (next === api.ui.nav.commitCursor) return;
|
|
165
|
-
api.ui.nav.commitCursor = next;
|
|
166
|
-
api.ui.status = '';
|
|
167
|
-
};
|
|
103
|
+
refresh() {
|
|
104
|
+
if (!this.ui.repo.listCommits || !this.loadCommits()) return;
|
|
105
|
+
const last = listedCommits(this.commits).length - 1;
|
|
106
|
+
const nav = this.ui.nav;
|
|
107
|
+
if (nav.commitCursor > last) nav.commitCursor = Math.max(0, last);
|
|
108
|
+
}
|
|
168
109
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
ui.mode = 'review';
|
|
173
|
-
ui.composer.state.commitKind = null;
|
|
174
|
-
ui.status = 'nothing to commit';
|
|
175
|
-
return;
|
|
110
|
+
refreshAfterWrite(extra = {}) {
|
|
111
|
+
this.refresh();
|
|
112
|
+
this.ui.refreshFromRepo({ keepEmpty: true, ...extra });
|
|
176
113
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
if (
|
|
114
|
+
|
|
115
|
+
indexForView() {
|
|
116
|
+
const ui = this.ui;
|
|
117
|
+
if (hasStagedChanges(ui)) return 0;
|
|
118
|
+
const list = listedCommits(this.commits);
|
|
119
|
+
const want = `${ui.rev ?? ''}`;
|
|
120
|
+
const short = `${ui.revShort ?? ''}`;
|
|
121
|
+
if (!want && !short) return 0;
|
|
122
|
+
for (let i = 0; i < list.length; i++) {
|
|
123
|
+
const entry = list[i];
|
|
124
|
+
if (entry.pending) continue;
|
|
125
|
+
const sha = `${entry.sha ?? ''}`;
|
|
126
|
+
const brief = `${entry.shortSha ?? ''}`;
|
|
127
|
+
if (want && sha === want) return i;
|
|
128
|
+
if (short && (brief === short || sha.startsWith(short))) return i;
|
|
129
|
+
}
|
|
130
|
+
return 0;
|
|
185
131
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
132
|
+
|
|
133
|
+
show() {
|
|
134
|
+
const ui = this.ui;
|
|
135
|
+
if (ui.mode === 'compose') return;
|
|
136
|
+
if (!ui.repo.listCommits) {
|
|
137
|
+
ui.status = 'read only';
|
|
138
|
+
return;
|
|
193
139
|
}
|
|
140
|
+
if (!this.loadCommits()) return;
|
|
141
|
+
const nav = ui.nav;
|
|
142
|
+
nav.commitCursor = this.indexForView();
|
|
143
|
+
nav.pane = 'commits';
|
|
144
|
+
nav.resetListScroll('commits');
|
|
145
|
+
ui.status = '';
|
|
146
|
+
nav.clearSelection();
|
|
194
147
|
}
|
|
195
|
-
ui.composer.state.commitBody = '';
|
|
196
|
-
if (isInPlaceCommit(kind)) text = keepBriefBody(ui, text);
|
|
197
|
-
ui.composer.state.commitKind = kind;
|
|
198
|
-
ui.composer.openCompose('commit', text);
|
|
199
|
-
const editor = ui.composer.state.editor;
|
|
200
|
-
if (!editor) return;
|
|
201
|
-
const lineEnd = editor.text.indexOf('\n');
|
|
202
|
-
editor.cursor = lineEnd < 0 ? editor.text.length : lineEnd;
|
|
203
|
-
};
|
|
204
148
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
149
|
+
onCommitMove(delta) {
|
|
150
|
+
const nav = this.ui.nav;
|
|
151
|
+
if (this.ui.mode === 'compose') return;
|
|
152
|
+
const last = listedCommits(this.commits).length - 1;
|
|
153
|
+
const next = Math.min(last, Math.max(0, nav.commitCursor + delta));
|
|
154
|
+
if (next === nav.commitCursor) return;
|
|
155
|
+
nav.commitCursor = next;
|
|
156
|
+
this.ui.status = '';
|
|
157
|
+
}
|
|
211
158
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
159
|
+
messageFor(kind) {
|
|
160
|
+
const ui = this.ui;
|
|
161
|
+
if (kind === 'fixup') return fixupMessage(this.selected());
|
|
162
|
+
if (kind === 'amend') {
|
|
163
|
+
const headAt = this.commits.findIndex((entry) => entry.head);
|
|
164
|
+
const at = headAt < 0 ? 0 : headAt;
|
|
165
|
+
ui.nav.commitCursor = this.commits.length ? at + 1 : 0;
|
|
166
|
+
if (ui.repo.lastMessage) return ui.repo.lastMessage(ui.top) ?? '';
|
|
167
|
+
return '';
|
|
168
|
+
}
|
|
169
|
+
if (kind === 'reword') {
|
|
170
|
+
const entry = this.selected();
|
|
171
|
+
if (!entry || !entry.sha) return null;
|
|
172
|
+
if (!ui.repo.commitMessage) return commitText(entry);
|
|
173
|
+
return ui.repo.commitMessage(ui.top, entry.sha) ?? '';
|
|
174
|
+
}
|
|
175
|
+
ui.nav.commitCursor = 0;
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
221
178
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
179
|
+
start(kind) {
|
|
180
|
+
const ui = this.ui;
|
|
181
|
+
const composer = ui.composer;
|
|
182
|
+
if (!isInPlaceCommit(kind) && !hasStagedChanges(ui)) {
|
|
183
|
+
ui.mode = 'review';
|
|
184
|
+
composer.commitKind = null;
|
|
185
|
+
ui.status = 'nothing to commit';
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
let text = this.messageFor(kind);
|
|
189
|
+
if (text === null) return;
|
|
190
|
+
composer.commitBody = '';
|
|
191
|
+
if (isInPlaceCommit(kind) && this.brief) {
|
|
192
|
+
const parts = splitMessage(text);
|
|
193
|
+
composer.commitBody = parts.rest;
|
|
194
|
+
text = parts.line;
|
|
195
|
+
}
|
|
196
|
+
composer.commitKind = kind;
|
|
197
|
+
ui.composer.openCompose('commit', text);
|
|
198
|
+
const editor = composer.editor;
|
|
199
|
+
const lineEnd = editor.text.indexOf('\n');
|
|
200
|
+
editor.cursor = lineEnd < 0 ? editor.text.length : lineEnd;
|
|
235
201
|
}
|
|
236
|
-
ui.refreshFromRepo({
|
|
237
|
-
keepEmpty: true,
|
|
238
|
-
afterLoad: () => openLoadedDiff(ui),
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
202
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
203
|
+
onInsert() {
|
|
204
|
+
const entry = this.selected();
|
|
205
|
+
if (!entry || entry.pending || !entry.sha) {
|
|
206
|
+
if (this.canCommit()) this.start('commit');
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!this.canWrite()) return;
|
|
210
|
+
this.ui.status = '';
|
|
211
|
+
this.ui.mode = 'confirmCommit';
|
|
212
|
+
}
|
|
247
213
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
214
|
+
chooseCommit(kind) {
|
|
215
|
+
this.ui.mode = 'review';
|
|
216
|
+
if (kind === 'amend') {
|
|
217
|
+
this.onAmend();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (kind === 'fixup') {
|
|
221
|
+
this.onFixup();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
this.start('commit');
|
|
225
|
+
}
|
|
253
226
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (!entry || !entry.sha) return;
|
|
257
|
-
const done = 'applied';
|
|
258
|
-
const repo = api.ui.repo;
|
|
259
|
-
if (!repo.applyFixup) {
|
|
260
|
-
api.ui.status = 'read only';
|
|
261
|
-
return;
|
|
227
|
+
cancelCommitChoice() {
|
|
228
|
+
this.ui.mode = 'review';
|
|
262
229
|
}
|
|
263
|
-
api.ui.ops.runWrite('applyFixup', [entry.sha], 'applying', done, (extra) =>
|
|
264
|
-
refreshAfterWrite(api, extra),
|
|
265
|
-
);
|
|
266
|
-
};
|
|
267
230
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (isFixupCommit(entry)) return void applyFixupNow(api);
|
|
273
|
-
startGitCommit(api, 'amend');
|
|
274
|
-
};
|
|
231
|
+
onCommit() {
|
|
232
|
+
if (this.ui.nav.pane === 'commits') return;
|
|
233
|
+
this.show();
|
|
234
|
+
}
|
|
275
235
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
236
|
+
onShowDiff() {
|
|
237
|
+
const ui = this.ui;
|
|
238
|
+
if (ui.mode === 'compose') return;
|
|
239
|
+
const entry = this.selected();
|
|
240
|
+
if (!entry) return;
|
|
241
|
+
const viewingCommit = Boolean(ui.rev || ui.revShort);
|
|
242
|
+
if (entry.pending && !viewingCommit) return void this.onInsert();
|
|
243
|
+
const sha = entry.pending ? '' : entry.sha || '';
|
|
244
|
+
ui.rev = sha;
|
|
245
|
+
ui.revShort = sha ? entry.shortSha || '' : '';
|
|
246
|
+
const afterLoad = () => {
|
|
247
|
+
const nav = ui.nav;
|
|
248
|
+
nav.tasksOpen = false;
|
|
249
|
+
nav.scroll = 0;
|
|
250
|
+
nav.index = 0;
|
|
251
|
+
nav.pane = ui.items.length ? 'diff' : 'files';
|
|
252
|
+
ui.syncReviewPath();
|
|
253
|
+
ui.syncFileCursor();
|
|
254
|
+
ui.status = '';
|
|
255
|
+
};
|
|
256
|
+
ui.refreshFromRepo({ keepEmpty: true, afterLoad });
|
|
257
|
+
}
|
|
281
258
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const run = (top) => write(top, kind, message);
|
|
286
|
-
const after = () => refreshAfterWrite(api, { doneStatus: done });
|
|
287
|
-
return void ui.ops.runBusy('committing', done, run, after);
|
|
288
|
-
};
|
|
259
|
+
onAmend() {
|
|
260
|
+
if (this.canWrite()) this.start('amend');
|
|
261
|
+
}
|
|
289
262
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
try {
|
|
293
|
-
ui.repo.commit(ui.top, kind, message);
|
|
294
|
-
} catch (error) {
|
|
295
|
-
ui.status = error.message;
|
|
296
|
-
return;
|
|
263
|
+
onReword() {
|
|
264
|
+
if (this.canWrite()) this.start('reword');
|
|
297
265
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (!ui.done && !ui.pendingExtras) {
|
|
302
|
-
ui.status = done;
|
|
266
|
+
|
|
267
|
+
onFixup() {
|
|
268
|
+
if (this.canWrite()) this.start('fixup');
|
|
303
269
|
}
|
|
304
|
-
};
|
|
305
270
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
271
|
+
onApply() {
|
|
272
|
+
if (!this.canWrite()) return;
|
|
273
|
+
const entry = this.selected();
|
|
274
|
+
if (!isFixupCommit(entry)) return void this.start('amend');
|
|
275
|
+
if (!entry.sha) return;
|
|
276
|
+
if (!this.ui.repo.applyFixup) {
|
|
277
|
+
this.ui.status = 'read only';
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const after = (extra) => this.refreshAfterWrite(extra);
|
|
281
|
+
this.ui.ops.runWrite(
|
|
282
|
+
'applyFixup',
|
|
283
|
+
[entry.sha],
|
|
284
|
+
'applying',
|
|
285
|
+
'applied',
|
|
286
|
+
after,
|
|
287
|
+
);
|
|
312
288
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
289
|
+
|
|
290
|
+
runAsync(kind, done, run) {
|
|
291
|
+
this.ui.composer.closeCompose();
|
|
292
|
+
const after = () => this.refreshAfterWrite({ doneStatus: done });
|
|
293
|
+
this.ui.ops.runBusy(kind, done, run, after);
|
|
318
294
|
}
|
|
319
|
-
|
|
320
|
-
|
|
295
|
+
|
|
296
|
+
finishReword(message) {
|
|
297
|
+
const ui = this.ui;
|
|
298
|
+
const entry = this.selected();
|
|
299
|
+
if (!entry || !entry.sha || !ui.repo.reword) {
|
|
300
|
+
ui.status = 'read only';
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const done = COMMIT_STATUS.reword;
|
|
304
|
+
const picked = pickRepoWrite(ui.repo, 'reword', ui.uiOpen);
|
|
305
|
+
if (picked.async) {
|
|
306
|
+
const run = (top) => picked.write(top, entry.sha, message);
|
|
307
|
+
return void this.runAsync('rewording', done, run);
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
ui.repo.reword(ui.top, entry.sha, message);
|
|
311
|
+
} catch (error) {
|
|
312
|
+
ui.status = error.message;
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
321
315
|
ui.composer.closeCompose();
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return void ui.ops.runBusy('rewording', done, run, after);
|
|
316
|
+
this.refreshAfterWrite();
|
|
317
|
+
if (!ui.status) ui.status = done;
|
|
325
318
|
}
|
|
326
|
-
try {
|
|
327
|
-
repo.reword(ui.top, entry.sha, message);
|
|
328
|
-
} catch (error) {
|
|
329
|
-
ui.status = error.message;
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
ui.composer.closeCompose();
|
|
333
|
-
refreshAfterWrite(api);
|
|
334
|
-
if (!ui.status) ui.status = done;
|
|
335
|
-
};
|
|
336
319
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
320
|
+
finishGitCommit() {
|
|
321
|
+
const ui = this.ui;
|
|
322
|
+
const composer = ui.composer;
|
|
323
|
+
const kind = composer.commitKind;
|
|
324
|
+
let message = composer.editor ? composer.editor.text : '';
|
|
325
|
+
if (isInPlaceCommit(kind) && this.brief) {
|
|
326
|
+
message = joinMessage(message, composer.commitBody);
|
|
327
|
+
}
|
|
328
|
+
message = tidyCommitMessage(message);
|
|
329
|
+
if (!message.trim()) {
|
|
330
|
+
ui.status = 'empty commit message';
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (!isInPlaceCommit(kind) && !hasStagedChanges(ui)) {
|
|
334
|
+
ui.composer.closeCompose();
|
|
335
|
+
ui.status = 'nothing to commit';
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (kind === 'reword') return void this.finishReword(message);
|
|
339
|
+
const done = COMMIT_STATUS[kind] ?? 'committed';
|
|
340
|
+
const picked = pickRepoWrite(ui.repo, 'commit', ui.uiOpen);
|
|
341
|
+
if (picked.async) {
|
|
342
|
+
const run = (top) => picked.write(top, kind, message);
|
|
343
|
+
return void this.runAsync('committing', done, run);
|
|
344
|
+
}
|
|
345
|
+
try {
|
|
346
|
+
ui.repo.commit(ui.top, kind, message);
|
|
347
|
+
} catch (error) {
|
|
348
|
+
ui.status = error.message;
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
351
|
ui.composer.closeCompose();
|
|
352
|
-
ui.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (kind === 'reword') return void finishReword(api, message);
|
|
356
|
-
const done = COMMIT_STATUS[kind] ?? 'committed';
|
|
357
|
-
const uiOpen = ui.uiOpen;
|
|
358
|
-
const picked = pickRepoWrite(ui.repo, 'commit', uiOpen);
|
|
359
|
-
if (picked.async) {
|
|
360
|
-
return void finishAsyncCommit(api, kind, message, done, picked.write);
|
|
352
|
+
ui.collection.clearDismissed();
|
|
353
|
+
this.refreshAfterWrite();
|
|
354
|
+
if (!ui.done && !ui.pendingExtras) ui.status = done;
|
|
361
355
|
}
|
|
362
|
-
finishSyncCommit(api, kind, message, done);
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
const onDropCommit = (api) => {
|
|
366
|
-
if (api.ui.nav.pane !== 'commits') return;
|
|
367
|
-
if (!canCommit(api.ui)) return;
|
|
368
|
-
const entry = selectedCommit(api);
|
|
369
|
-
if (!entry) return;
|
|
370
|
-
api.state.dropName = entry.shortSha || entry.sha;
|
|
371
|
-
api.state.dropSha = entry.sha;
|
|
372
|
-
api.ui.mode = 'confirmDrop';
|
|
373
|
-
api.ui.status = '';
|
|
374
|
-
};
|
|
375
356
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const sha = api.state.dropSha;
|
|
385
|
-
const name = api.state.dropName;
|
|
386
|
-
api.ui.mode = 'review';
|
|
387
|
-
api.state.dropName = '';
|
|
388
|
-
api.state.dropSha = '';
|
|
389
|
-
if (!sha) return;
|
|
390
|
-
const done = `dropped ${name}`;
|
|
391
|
-
const repo = api.ui.repo;
|
|
392
|
-
if (!repo.dropCommit) {
|
|
393
|
-
api.ui.status = 'read only';
|
|
394
|
-
return;
|
|
357
|
+
onDropCommit() {
|
|
358
|
+
if (!this.canWrite()) return;
|
|
359
|
+
const entry = this.selected();
|
|
360
|
+
if (!entry) return;
|
|
361
|
+
this.dropName = entry.shortSha || entry.sha;
|
|
362
|
+
this.dropSha = entry.sha;
|
|
363
|
+
this.ui.mode = 'confirmDrop';
|
|
364
|
+
this.ui.status = '';
|
|
395
365
|
}
|
|
396
|
-
api.ui.ops.runWrite('dropCommit', [sha], 'dropping', done, (extra) =>
|
|
397
|
-
refreshAfterWrite(api, extra),
|
|
398
|
-
);
|
|
399
|
-
};
|
|
400
366
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
};
|
|
367
|
+
cancelDropCommit() {
|
|
368
|
+
this.ui.mode = 'review';
|
|
369
|
+
this.dropName = '';
|
|
370
|
+
this.dropSha = '';
|
|
371
|
+
this.ui.status = '';
|
|
372
|
+
}
|
|
408
373
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
374
|
+
confirmDropCommit() {
|
|
375
|
+
const sha = this.dropSha;
|
|
376
|
+
const done = `dropped ${this.dropName}`;
|
|
377
|
+
this.ui.mode = 'review';
|
|
378
|
+
this.dropName = '';
|
|
379
|
+
this.dropSha = '';
|
|
380
|
+
if (!sha) return;
|
|
381
|
+
if (!this.ui.repo.dropCommit) {
|
|
382
|
+
this.ui.status = 'read only';
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const after = (extra) => this.refreshAfterWrite(extra);
|
|
386
|
+
this.ui.ops.runWrite('dropCommit', [sha], 'dropping', done, after);
|
|
387
|
+
}
|
|
415
388
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
const api = { ui, state };
|
|
424
|
-
return stateView(
|
|
425
|
-
state,
|
|
426
|
-
{
|
|
427
|
-
reset: () => reset(state),
|
|
428
|
-
canCommit: () => canCommit(ui),
|
|
429
|
-
onCommit: () => onCommit(api),
|
|
430
|
-
onAmend: () => onAmend(api),
|
|
431
|
-
onReword: () => onReword(api),
|
|
432
|
-
onApply: () => onApply(api),
|
|
433
|
-
onFixup: () => onFixup(api),
|
|
434
|
-
onCommitMove: (delta) => onCommitMove(api, delta),
|
|
435
|
-
onShowDiff: () => showSelectedDiff(api),
|
|
436
|
-
onView: () => onView(api),
|
|
437
|
-
finishGitCommit: () => finishGitCommit(api),
|
|
438
|
-
refresh: () => refreshCommitList(api),
|
|
439
|
-
onDropCommit: () => onDropCommit(api),
|
|
440
|
-
cancelDropCommit: () => cancelDropCommit(api),
|
|
441
|
-
confirmDropCommit: () => confirmDropCommit(api),
|
|
442
|
-
},
|
|
443
|
-
['commits', 'dropName', 'commitView'],
|
|
444
|
-
);
|
|
445
|
-
};
|
|
389
|
+
onView() {
|
|
390
|
+
if (this.ui.nav.pane !== 'commits') return;
|
|
391
|
+
this.commitView = this.brief ? 'full' : 'brief';
|
|
392
|
+
this.ui.nav.listScroll = 0;
|
|
393
|
+
this.ui.status = this.commitView;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
446
396
|
|
|
447
|
-
module.exports = {
|
|
448
|
-
hasStagedChanges,
|
|
449
|
-
createCommitController,
|
|
450
|
-
listedCommits,
|
|
451
|
-
};
|
|
397
|
+
module.exports = { hasStagedChanges, listedCommits, CommitController };
|