diff --git a/src/commands.ts b/src/commands.ts index c25b3c9d..03f08a5e 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -154,13 +154,13 @@ export class SvnCommands implements IDisposable { @command("svn.commitWithMessage", { repository: true }) async commitWithMessage(repository: Repository) { - const message = repository.inputBox.value; - if (!message) { + const choice = await inputCommitChangelist(repository); + if (!choice) { return; } - const choice = await inputCommitChangelist(repository); - if (!choice) { + const message = await inputCommitMessage(repository.inputBox.value, false); + if (message === undefined) { return; } @@ -183,7 +183,7 @@ export class SvnCommands implements IDisposable { repository.inputBox.value = ""; } catch (error) { console.error(error); - window.showErrorMessage("Unable to commit"); + window.showErrorMessage(error.stderrFormated); } } @@ -311,17 +311,20 @@ export class SvnCommands implements IDisposable { const paths = resources.map(resource => resource.fsPath); try { - const message = await inputCommitMessage(); + const message = await inputCommitMessage(repository.inputBox.value); if (message === undefined) { return; } + repository.inputBox.value = message; + const result = await repository.commitFiles(message, paths); window.showInformationMessage(result); + repository.inputBox.value = ""; } catch (error) { console.error(error); - window.showErrorMessage("Unable to commit"); + window.showErrorMessage(error.stderrFormated); } }); } diff --git a/src/messages.ts b/src/messages.ts index 63c24fd1..ebf7ccf1 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -4,20 +4,31 @@ export function noChangesToCommit() { return window.showInformationMessage("There are no changes to commit."); } -export function inputCommitMessage(message?: string) { - return new Promise((resolve, reject) => { - if (message) { - resolve(message); - return; - } +export async function inputCommitMessage( + message?: string, + promptNew: boolean = true +): Promise { + if (promptNew) { + message = await window.showInputBox({ + value: message, + placeHolder: "Commit message", + prompt: "Please enter a commit message", + ignoreFocusOut: true + }); + } + + if (!message) { + const allowEmpty = await window.showWarningMessage( + "Do you really want to commit an empty message?", + { modal: true }, + "Yes" + ); - window - .showInputBox({ - value: "", - placeHolder: "Commit message", - prompt: "Please enter a commit message", - ignoreFocusOut: true - }) - .then(input => resolve(input)); - }); + if (allowEmpty === "Yes") { + return ""; + } else { + return undefined; + } + } + return message; } diff --git a/src/svn.ts b/src/svn.ts index 420e51bb..6962bc43 100644 --- a/src/svn.ts +++ b/src/svn.ts @@ -73,6 +73,7 @@ export interface ISvnErrorData { message?: string; stdout?: string; stderr?: string; + stderrFormated?: string; exitCode?: number; svnErrorCode?: string; svnCommand?: string; @@ -110,6 +111,7 @@ export class SvnError { message: string; stdout?: string; stderr?: string; + stderrFormated?: string; exitCode?: number; svnErrorCode?: string; svnCommand?: string; @@ -125,6 +127,7 @@ export class SvnError { this.message = data.message || "SVN error"; this.stdout = data.stdout; this.stderr = data.stderr; + this.stderrFormated = data.stderrFormated; this.exitCode = data.exitCode; this.svnErrorCode = data.svnErrorCode; this.svnCommand = data.svnCommand; @@ -184,7 +187,7 @@ export class Svn { } if (options.log !== false) { - const argsOut = args.map(arg => (/ /.test(arg) ? `'${arg}'` : arg)); + const argsOut = args.map(arg => (/ |^$/.test(arg) ? `'${arg}'` : arg)); this.logOutput( `[${this.lastCwd.split(/[\\\/]+/).pop()}]$ svn ${argsOut.join(" ")}\n` ); @@ -281,6 +284,7 @@ export class Svn { message: "Failed to execute svn", stdout: stdout, stderr: stderr, + stderrFormated: stderr.replace(/^svn: E\d+: +/gm, ""), exitCode: exitCode, svnErrorCode: getSvnErrorCode(stderr), svnCommand: args[0]