Skip to content

Commit f8d4da0

Browse files
committed
Added warning message if empty (Close #235,#240)
1 parent fe6e75c commit f8d4da0

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

src/commands.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ export class SvnCommands implements IDisposable {
154154

155155
@command("svn.commitWithMessage", { repository: true })
156156
async commitWithMessage(repository: Repository) {
157-
const message = repository.inputBox.value;
158-
if (!message) {
157+
const choice = await inputCommitChangelist(repository);
158+
if (!choice) {
159159
return;
160160
}
161161

162-
const choice = await inputCommitChangelist(repository);
163-
if (!choice) {
162+
const message = await inputCommitMessage(repository.inputBox.value, false);
163+
if (message === undefined) {
164164
return;
165165
}
166166

@@ -311,14 +311,17 @@ export class SvnCommands implements IDisposable {
311311
const paths = resources.map(resource => resource.fsPath);
312312

313313
try {
314-
const message = await inputCommitMessage();
314+
const message = await inputCommitMessage(repository.inputBox.value);
315315

316316
if (message === undefined) {
317317
return;
318318
}
319319

320+
repository.inputBox.value = message;
321+
320322
const result = await repository.commitFiles(message, paths);
321323
window.showInformationMessage(result);
324+
repository.inputBox.value = "";
322325
} catch (error) {
323326
console.error(error);
324327
window.showErrorMessage("Unable to commit");

src/messages.ts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,31 @@ export function noChangesToCommit() {
44
return window.showInformationMessage("There are no changes to commit.");
55
}
66

7-
export function inputCommitMessage(message?: string) {
8-
return new Promise<string>((resolve, reject) => {
9-
if (message) {
10-
resolve(message);
11-
return;
12-
}
7+
export async function inputCommitMessage(
8+
message?: string,
9+
promptNew: boolean = true
10+
): Promise<string | undefined> {
11+
if (promptNew) {
12+
message = await window.showInputBox({
13+
value: message,
14+
placeHolder: "Commit message",
15+
prompt: "Please enter a commit message",
16+
ignoreFocusOut: true
17+
});
18+
}
19+
20+
if (!message) {
21+
const allowEmpty = await window.showWarningMessage(
22+
"Do you really want to commit an empty message?",
23+
{ modal: true },
24+
"Yes"
25+
);
1326

14-
window
15-
.showInputBox({
16-
value: "",
17-
placeHolder: "Commit message",
18-
prompt: "Please enter a commit message",
19-
ignoreFocusOut: true
20-
})
21-
.then(input => resolve(input));
22-
});
27+
if (allowEmpty === "Yes") {
28+
return "";
29+
} else {
30+
return undefined;
31+
}
32+
}
33+
return message;
2334
}

src/svn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export class Svn {
184184
}
185185

186186
if (options.log !== false) {
187-
const argsOut = args.map(arg => (/ /.test(arg) ? `'${arg}'` : arg));
187+
const argsOut = args.map(arg => (/ |^$/.test(arg) ? `'${arg}'` : arg));
188188
this.logOutput(
189189
`[${this.lastCwd.split(/[\\\/]+/).pop()}]$ svn ${argsOut.join(" ")}\n`
190190
);

0 commit comments

Comments
 (0)