Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Commit baa8d0c

Browse files
committed
Show message when trying to commit with no staged files
1 parent ae939f4 commit baa8d0c

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/views/status.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,24 @@ module.exports = class Status {
101101

102102
if (connection) {
103103
if (repo.canUseGit() && await repo.isGitRepo()) {
104-
const message = await vscode.window.showInputBox({
105-
prompt: `Commit message`
106-
});
107-
108-
if (message) {
109-
try {
110-
await repo.commit(message);
111-
await vscode.commands.executeCommand(`git-client-ibmi.commits.refresh`);
112-
vscode.window.showInformationMessage(`Commit successful.`);
113-
} catch (e) {
114-
vscode.window.showErrorMessage(`Error making commit in ${repoPath}. ${e}`);
115-
}
104+
if (this.status && this.status.staged && this.status.staged.length > 0) {
105+
const message = await vscode.window.showInputBox({
106+
prompt: `Commit message`
107+
});
116108

117-
this.refresh();
109+
if (message) {
110+
try {
111+
await repo.commit(message);
112+
await vscode.commands.executeCommand(`git-client-ibmi.commits.refresh`);
113+
vscode.window.showInformationMessage(`Commit successful.`);
114+
} catch (e) {
115+
vscode.window.showErrorMessage(`Error making commit in ${repoPath}. ${e}`);
116+
}
117+
118+
this.refresh();
119+
}
120+
} else {
121+
vscode.window.showErrorMessage(`To make a commit you must stage your changes.`);
118122
}
119123
}
120124
}

0 commit comments

Comments
 (0)