Skip to content

Commit

Permalink
fixes #40295
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Nov 10, 2020
1 parent ad88db1 commit e8b6953
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1583,9 +1583,9 @@ export class CommandCenter {
}
}

const message = await getCommitMessage();
let message = await getCommitMessage();

if (!message) {
if (!message && !opts.amend) {
return false;
}

Expand Down Expand Up @@ -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;
Expand Down
14 changes: 10 additions & 4 deletions extensions/git/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e8b6953

Please sign in to comment.