未验证 提交 e8b69537 编写于 作者: J João Moreno

fixes #40295

上级 ad88db10
......@@ -1583,9 +1583,9 @@ export class CommandCenter {
}
}
const message = await getCommitMessage();
let message = await getCommitMessage();
if (!message) {
if (!message && !opts.amend) {
return false;
}
......@@ -1622,7 +1622,7 @@ export class CommandCenter {
let value: string | undefined = undefined;
if (opts && opts.amend && repository.HEAD && repository.HEAD.commit) {
value = (await repository.getCommit(repository.HEAD.commit)).message;
return undefined;
}
const branchName = repository.headShortName;
......
......@@ -1332,17 +1332,23 @@ export class Repository {
}
}
async commit(message: string, opts: CommitOptions = Object.create(null)): Promise<void> {
const args = ['commit', '--quiet', '--allow-empty-message', '--file', '-'];
async commit(message: string | undefined, opts: CommitOptions = Object.create(null)): Promise<void> {
const args = ['commit', '--quiet', '--allow-empty-message'];
if (opts.all) {
args.push('--all');
}
if (opts.amend) {
if (opts.amend && message) {
args.push('--amend');
}
if (opts.amend && !message) {
args.push('--amend', '--no-edit');
} else {
args.push('--file', '-');
}
if (opts.signoff) {
args.push('--signoff');
}
......@@ -1360,7 +1366,7 @@ export class Repository {
}
try {
await this.run(args, { input: message || '' });
await this.run(args, !opts.amend || message ? { input: message || '' } : {});
} catch (commitErr) {
await this.handleCommitError(commitErr);
}
......
......@@ -985,7 +985,7 @@ export class Repository implements Disposable {
await this.run(Operation.RevertFiles, () => this.repository.revert('HEAD', resources.map(r => r.fsPath)));
}
async commit(message: string, opts: CommitOptions = Object.create(null)): Promise<void> {
async commit(message: string | undefined, opts: CommitOptions = Object.create(null)): Promise<void> {
if (this.rebaseCommit) {
await this.run(Operation.RebaseContinue, async () => {
if (opts.all) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册