Git - Add Commit (Amend) to the Commit Action button (#187568)

This commit is contained in:
Ladislau Szomoru 2023-07-11 14:24:23 +02:00 committed by GitHub
parent f0db763ba9
commit f254ad1758
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 103 additions and 16 deletions

View file

@ -254,6 +254,20 @@
"icon": "$(check)",
"enablement": "!operationInProgress"
},
{
"command": "git.commitAmend",
"title": "%command.commitAmend%",
"category": "Git",
"icon": "$(check)",
"enablement": "!operationInProgress"
},
{
"command": "git.commitSigned",
"title": "%command.commitSigned%",
"category": "Git",
"icon": "$(check)",
"enablement": "!operationInProgress"
},
{
"command": "git.commitStaged",
"title": "%command.commitStaged%",
@ -321,6 +335,18 @@
"category": "Git",
"enablement": "!operationInProgress"
},
{
"command": "git.commitAmendNoVerify",
"title": "%command.commitAmendNoVerify%",
"category": "Git",
"enablement": "!operationInProgress"
},
{
"command": "git.commitSignedNoVerify",
"title": "%command.commitSignedNoVerify%",
"category": "Git",
"enablement": "!operationInProgress"
},
{
"command": "git.commitStagedAmendNoVerify",
"title": "%command.commitStagedAmendNoVerify%",
@ -873,6 +899,14 @@
"command": "git.commit",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
},
{
"command": "git.commitAmend",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
},
{
"command": "git.commitSigned",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
},
{
"command": "git.commitStaged",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
@ -921,6 +955,14 @@
"command": "git.commitStagedSignedNoVerify",
"when": "config.git.enabled && !git.missing && config.git.allowNoVerifyCommit && gitOpenRepositoryCount != 0"
},
{
"command": "git.commitAmendNoVerify",
"when": "config.git.enabled && !git.missing && config.git.allowNoVerifyCommit && gitOpenRepositoryCount != 0"
},
{
"command": "git.commitSignedNoVerify",
"when": "config.git.enabled && !git.missing && config.git.allowNoVerifyCommit && gitOpenRepositoryCount != 0"
},
{
"command": "git.commitStagedAmendNoVerify",
"when": "config.git.enabled && !git.missing && config.git.allowNoVerifyCommit && gitOpenRepositoryCount != 0"
@ -1772,53 +1814,71 @@
},
{
"command": "git.commitNoVerify",
"group": "1_commit@6",
"group": "2_commit_noverify@1",
"when": "config.git.allowNoVerifyCommit"
},
{
"command": "git.commitStagedNoVerify",
"group": "1_commit@7",
"group": "2_commit_noverify@2",
"when": "config.git.allowNoVerifyCommit"
},
{
"command": "git.commitAllNoVerify",
"group": "1_commit@8",
"group": "2_commit_noverify@3",
"when": "config.git.allowNoVerifyCommit"
},
{
"command": "git.commitAmend",
"group": "3_amend@1"
},
{
"command": "git.commitStagedAmend",
"group": "2_amend@1"
"group": "3_amend@2"
},
{
"command": "git.commitAllAmend",
"group": "2_amend@2"
"group": "3_amend@3"
},
{
"command": "git.commitAmendNoVerify",
"group": "4_amend_noverify@1",
"when": "config.git.allowNoVerifyCommit"
},
{
"command": "git.commitStagedAmendNoVerify",
"group": "2_amend@3",
"group": "4_amend_noverify@2",
"when": "config.git.allowNoVerifyCommit"
},
{
"command": "git.commitAllAmendNoVerify",
"group": "2_amend@4",
"group": "4_amend_noverify@3",
"when": "config.git.allowNoVerifyCommit"
},
{
"command": "git.commitSigned",
"group": "5_signoff@1"
},
{
"command": "git.commitStagedSigned",
"group": "3_signoff@1"
"group": "5_signoff@2"
},
{
"command": "git.commitAllSigned",
"group": "3_signoff@2"
"group": "5_signoff@3"
},
{
"command": "git.commitSignedNoVerify",
"group": "6_signoff_noverify@1",
"when": "config.git.allowNoVerifyCommit"
},
{
"command": "git.commitStagedSignedNoVerify",
"group": "3_signoff@3",
"group": "6_signoff_noverify@2",
"when": "config.git.allowNoVerifyCommit"
},
{
"command": "git.commitAllSignedNoVerify",
"group": "3_signoff@4",
"group": "6_signoff_noverify@3",
"when": "config.git.allowNoVerifyCommit"
}
],

View file

@ -33,6 +33,8 @@
"command.cleanAllUntracked": "Discard All Untracked Changes",
"command.closeAllDiffEditors": "Close All Diff Editors",
"command.commit": "Commit",
"command.commitAmend": "Commit (Amend)",
"command.commitSigned": "Commit (Signed Off)",
"command.commitStaged": "Commit Staged",
"command.commitEmpty": "Commit Empty",
"command.commitStagedSigned": "Commit Staged (Signed Off)",
@ -44,6 +46,8 @@
"command.commitStagedNoVerify": "Commit Staged (No Verify)",
"command.commitEmptyNoVerify": "Commit Empty (No Verify)",
"command.commitStagedSignedNoVerify": "Commit Staged (Signed Off, No Verify)",
"command.commitAmendNoVerify": "Commit (Amend, No Verify)",
"command.commitSignedNoVerify": "Commit (Signed Off, No Verify)",
"command.commitStagedAmendNoVerify": "Commit Staged (Amend, No Verify)",
"command.commitAllNoVerify": "Commit All (No Verify)",
"command.commitAllSignedNoVerify": "Commit All (Signed Off, No Verify)",

View file

@ -126,7 +126,7 @@ export class ActionButtonCommand {
const commandGroups: Command[][] = [];
for (const commands of this.postCommitCommandCenter.getSecondaryCommands()) {
commandGroups.push(commands.map(c => {
return { command: 'git.commit', title: c.title, tooltip: c.tooltip, arguments: c.arguments };
return { command: c.command, title: c.title, tooltip: c.tooltip, arguments: c.arguments };
}));
}

View file

@ -1973,6 +1973,16 @@ export class CommandCenter {
await this.commitWithAnyInput(repository, { postCommitCommand });
}
@command('git.commitAmend', { repository: true })
async commitAmend(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { amend: true });
}
@command('git.commitSigned', { repository: true })
async commitSigned(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { signoff: true });
}
@command('git.commitStaged', { repository: true })
async commitStaged(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { all: false });
@ -2091,6 +2101,16 @@ export class CommandCenter {
await this.commitWithAnyInput(repository, { all: false, signoff: true, noVerify: true });
}
@command('git.commitAmendNoVerify', { repository: true })
async commitAmendNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { amend: true, noVerify: true });
}
@command('git.commitSignedNoVerify', { repository: true })
async commitSignedNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { signoff: true, noVerify: true });
}
@command('git.commitStagedAmendNoVerify', { repository: true })
async commitStagedAmendNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { all: false, amend: true, noVerify: true });

View file

@ -117,7 +117,7 @@ export class CommitCommandsCenter {
const commandFromStorage = allCommands.find(c => c.arguments?.length === 2 && c.arguments[1] === this.getPostCommitCommandStringFromStorage());
const commandFromSetting = allCommands.find(c => c.arguments?.length === 2 && c.arguments[1] === this.getPostCommitCommandStringFromSetting());
return commandFromStorage ?? commandFromSetting ?? this.getCommitCommand();
return commandFromStorage ?? commandFromSetting ?? this.getCommitCommands()[0];
}
getSecondaryCommands(): Command[][] {
@ -131,7 +131,7 @@ export class CommitCommandsCenter {
}
if (commandGroups.length > 0) {
commandGroups[0].splice(0, 0, this.getCommitCommand());
commandGroups.splice(0, 0, this.getCommitCommands());
}
return commandGroups;
@ -169,7 +169,7 @@ export class CommitCommandsCenter {
return `postCommitCommand:${this.repository.root}`;
}
private getCommitCommand(): Command {
private getCommitCommands(): Command[] {
const config = workspace.getConfiguration('git', Uri.file(this.repository.root));
// Branch protection
@ -196,7 +196,10 @@ export class CommitCommandsCenter {
l10n.t('Committing Changes to New Branch...');
}
return { command: 'git.commit', title: l10n.t('{0} Commit', icon ?? '$(check)'), tooltip, arguments: [this.repository.sourceControl, null] };
return [
{ command: 'git.commit', title: l10n.t('{0} Commit', icon ?? '$(check)'), tooltip, arguments: [this.repository.sourceControl, null] },
{ command: 'git.commitAmend', title: l10n.t('{0} Commit (Amend)', icon ?? '$(check)'), tooltip, arguments: [this.repository.sourceControl, null] },
];
}
private getPostCommitCommandStringFromSetting(): string | undefined {