From f8d4da04df9570a8bce4a044268b2e3193aa2851 Mon Sep 17 00:00:00 2001 From: Edgard Lorraine Messias Date: Mon, 9 Apr 2018 14:11:35 -0300 Subject: [PATCH 1/2] Added warning message if empty (Close #235,#240) --- src/commands.ts | 13 ++++++++----- src/messages.ts | 41 ++++++++++++++++++++++++++--------------- src/svn.ts | 2 +- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index c25b3c9d..b8c87c49 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; } @@ -311,14 +311,17 @@ 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"); 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..29b065a7 100644 --- a/src/svn.ts +++ b/src/svn.ts @@ -184,7 +184,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` ); From 3305c68dae8c6e55fc8bdefa7e11a0be82b1598d Mon Sep 17 00:00:00 2001 From: Edgard Lorraine Messias Date: Mon, 9 Apr 2018 14:53:14 -0300 Subject: [PATCH 2/2] Added info of reason for commit failed (Close #236) --- src/commands.ts | 4 ++-- src/svn.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index b8c87c49..03f08a5e 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -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); } } @@ -324,7 +324,7 @@ export class SvnCommands implements IDisposable { repository.inputBox.value = ""; } catch (error) { console.error(error); - window.showErrorMessage("Unable to commit"); + window.showErrorMessage(error.stderrFormated); } }); } diff --git a/src/svn.ts b/src/svn.ts index 29b065a7..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; @@ -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]