Skip to content

Commit f254ad1

Browse files
authored
Git - Add Commit (Amend) to the Commit Action button (microsoft#187568)
1 parent f0db763 commit f254ad1

File tree

5 files changed

+103
-16
lines changed

5 files changed

+103
-16
lines changed

extensions/git/package.json

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,20 @@
254254
"icon": "$(check)",
255255
"enablement": "!operationInProgress"
256256
},
257+
{
258+
"command": "git.commitAmend",
259+
"title": "%command.commitAmend%",
260+
"category": "Git",
261+
"icon": "$(check)",
262+
"enablement": "!operationInProgress"
263+
},
264+
{
265+
"command": "git.commitSigned",
266+
"title": "%command.commitSigned%",
267+
"category": "Git",
268+
"icon": "$(check)",
269+
"enablement": "!operationInProgress"
270+
},
257271
{
258272
"command": "git.commitStaged",
259273
"title": "%command.commitStaged%",
@@ -321,6 +335,18 @@
321335
"category": "Git",
322336
"enablement": "!operationInProgress"
323337
},
338+
{
339+
"command": "git.commitAmendNoVerify",
340+
"title": "%command.commitAmendNoVerify%",
341+
"category": "Git",
342+
"enablement": "!operationInProgress"
343+
},
344+
{
345+
"command": "git.commitSignedNoVerify",
346+
"title": "%command.commitSignedNoVerify%",
347+
"category": "Git",
348+
"enablement": "!operationInProgress"
349+
},
324350
{
325351
"command": "git.commitStagedAmendNoVerify",
326352
"title": "%command.commitStagedAmendNoVerify%",
@@ -873,6 +899,14 @@
873899
"command": "git.commit",
874900
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
875901
},
902+
{
903+
"command": "git.commitAmend",
904+
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
905+
},
906+
{
907+
"command": "git.commitSigned",
908+
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
909+
},
876910
{
877911
"command": "git.commitStaged",
878912
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
@@ -921,6 +955,14 @@
921955
"command": "git.commitStagedSignedNoVerify",
922956
"when": "config.git.enabled && !git.missing && config.git.allowNoVerifyCommit && gitOpenRepositoryCount != 0"
923957
},
958+
{
959+
"command": "git.commitAmendNoVerify",
960+
"when": "config.git.enabled && !git.missing && config.git.allowNoVerifyCommit && gitOpenRepositoryCount != 0"
961+
},
962+
{
963+
"command": "git.commitSignedNoVerify",
964+
"when": "config.git.enabled && !git.missing && config.git.allowNoVerifyCommit && gitOpenRepositoryCount != 0"
965+
},
924966
{
925967
"command": "git.commitStagedAmendNoVerify",
926968
"when": "config.git.enabled && !git.missing && config.git.allowNoVerifyCommit && gitOpenRepositoryCount != 0"
@@ -1772,53 +1814,71 @@
17721814
},
17731815
{
17741816
"command": "git.commitNoVerify",
1775-
"group": "1_commit@6",
1817+
"group": "2_commit_noverify@1",
17761818
"when": "config.git.allowNoVerifyCommit"
17771819
},
17781820
{
17791821
"command": "git.commitStagedNoVerify",
1780-
"group": "1_commit@7",
1822+
"group": "2_commit_noverify@2",
17811823
"when": "config.git.allowNoVerifyCommit"
17821824
},
17831825
{
17841826
"command": "git.commitAllNoVerify",
1785-
"group": "1_commit@8",
1827+
"group": "2_commit_noverify@3",
17861828
"when": "config.git.allowNoVerifyCommit"
17871829
},
1830+
{
1831+
"command": "git.commitAmend",
1832+
"group": "3_amend@1"
1833+
},
17881834
{
17891835
"command": "git.commitStagedAmend",
1790-
"group": "2_amend@1"
1836+
"group": "3_amend@2"
17911837
},
17921838
{
17931839
"command": "git.commitAllAmend",
1794-
"group": "2_amend@2"
1840+
"group": "3_amend@3"
1841+
},
1842+
{
1843+
"command": "git.commitAmendNoVerify",
1844+
"group": "4_amend_noverify@1",
1845+
"when": "config.git.allowNoVerifyCommit"
17951846
},
17961847
{
17971848
"command": "git.commitStagedAmendNoVerify",
1798-
"group": "2_amend@3",
1849+
"group": "4_amend_noverify@2",
17991850
"when": "config.git.allowNoVerifyCommit"
18001851
},
18011852
{
18021853
"command": "git.commitAllAmendNoVerify",
1803-
"group": "2_amend@4",
1854+
"group": "4_amend_noverify@3",
18041855
"when": "config.git.allowNoVerifyCommit"
18051856
},
1857+
{
1858+
"command": "git.commitSigned",
1859+
"group": "5_signoff@1"
1860+
},
18061861
{
18071862
"command": "git.commitStagedSigned",
1808-
"group": "3_signoff@1"
1863+
"group": "5_signoff@2"
18091864
},
18101865
{
18111866
"command": "git.commitAllSigned",
1812-
"group": "3_signoff@2"
1867+
"group": "5_signoff@3"
1868+
},
1869+
{
1870+
"command": "git.commitSignedNoVerify",
1871+
"group": "6_signoff_noverify@1",
1872+
"when": "config.git.allowNoVerifyCommit"
18131873
},
18141874
{
18151875
"command": "git.commitStagedSignedNoVerify",
1816-
"group": "3_signoff@3",
1876+
"group": "6_signoff_noverify@2",
18171877
"when": "config.git.allowNoVerifyCommit"
18181878
},
18191879
{
18201880
"command": "git.commitAllSignedNoVerify",
1821-
"group": "3_signoff@4",
1881+
"group": "6_signoff_noverify@3",
18221882
"when": "config.git.allowNoVerifyCommit"
18231883
}
18241884
],

extensions/git/package.nls.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
"command.cleanAllUntracked": "Discard All Untracked Changes",
3434
"command.closeAllDiffEditors": "Close All Diff Editors",
3535
"command.commit": "Commit",
36+
"command.commitAmend": "Commit (Amend)",
37+
"command.commitSigned": "Commit (Signed Off)",
3638
"command.commitStaged": "Commit Staged",
3739
"command.commitEmpty": "Commit Empty",
3840
"command.commitStagedSigned": "Commit Staged (Signed Off)",
@@ -44,6 +46,8 @@
4446
"command.commitStagedNoVerify": "Commit Staged (No Verify)",
4547
"command.commitEmptyNoVerify": "Commit Empty (No Verify)",
4648
"command.commitStagedSignedNoVerify": "Commit Staged (Signed Off, No Verify)",
49+
"command.commitAmendNoVerify": "Commit (Amend, No Verify)",
50+
"command.commitSignedNoVerify": "Commit (Signed Off, No Verify)",
4751
"command.commitStagedAmendNoVerify": "Commit Staged (Amend, No Verify)",
4852
"command.commitAllNoVerify": "Commit All (No Verify)",
4953
"command.commitAllSignedNoVerify": "Commit All (Signed Off, No Verify)",

extensions/git/src/actionButton.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class ActionButtonCommand {
126126
const commandGroups: Command[][] = [];
127127
for (const commands of this.postCommitCommandCenter.getSecondaryCommands()) {
128128
commandGroups.push(commands.map(c => {
129-
return { command: 'git.commit', title: c.title, tooltip: c.tooltip, arguments: c.arguments };
129+
return { command: c.command, title: c.title, tooltip: c.tooltip, arguments: c.arguments };
130130
}));
131131
}
132132

extensions/git/src/commands.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,16 @@ export class CommandCenter {
19731973
await this.commitWithAnyInput(repository, { postCommitCommand });
19741974
}
19751975

1976+
@command('git.commitAmend', { repository: true })
1977+
async commitAmend(repository: Repository): Promise<void> {
1978+
await this.commitWithAnyInput(repository, { amend: true });
1979+
}
1980+
1981+
@command('git.commitSigned', { repository: true })
1982+
async commitSigned(repository: Repository): Promise<void> {
1983+
await this.commitWithAnyInput(repository, { signoff: true });
1984+
}
1985+
19761986
@command('git.commitStaged', { repository: true })
19771987
async commitStaged(repository: Repository): Promise<void> {
19781988
await this.commitWithAnyInput(repository, { all: false });
@@ -2091,6 +2101,16 @@ export class CommandCenter {
20912101
await this.commitWithAnyInput(repository, { all: false, signoff: true, noVerify: true });
20922102
}
20932103

2104+
@command('git.commitAmendNoVerify', { repository: true })
2105+
async commitAmendNoVerify(repository: Repository): Promise<void> {
2106+
await this.commitWithAnyInput(repository, { amend: true, noVerify: true });
2107+
}
2108+
2109+
@command('git.commitSignedNoVerify', { repository: true })
2110+
async commitSignedNoVerify(repository: Repository): Promise<void> {
2111+
await this.commitWithAnyInput(repository, { signoff: true, noVerify: true });
2112+
}
2113+
20942114
@command('git.commitStagedAmendNoVerify', { repository: true })
20952115
async commitStagedAmendNoVerify(repository: Repository): Promise<void> {
20962116
await this.commitWithAnyInput(repository, { all: false, amend: true, noVerify: true });

extensions/git/src/postCommitCommands.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class CommitCommandsCenter {
117117
const commandFromStorage = allCommands.find(c => c.arguments?.length === 2 && c.arguments[1] === this.getPostCommitCommandStringFromStorage());
118118
const commandFromSetting = allCommands.find(c => c.arguments?.length === 2 && c.arguments[1] === this.getPostCommitCommandStringFromSetting());
119119

120-
return commandFromStorage ?? commandFromSetting ?? this.getCommitCommand();
120+
return commandFromStorage ?? commandFromSetting ?? this.getCommitCommands()[0];
121121
}
122122

123123
getSecondaryCommands(): Command[][] {
@@ -131,7 +131,7 @@ export class CommitCommandsCenter {
131131
}
132132

133133
if (commandGroups.length > 0) {
134-
commandGroups[0].splice(0, 0, this.getCommitCommand());
134+
commandGroups.splice(0, 0, this.getCommitCommands());
135135
}
136136

137137
return commandGroups;
@@ -169,7 +169,7 @@ export class CommitCommandsCenter {
169169
return `postCommitCommand:${this.repository.root}`;
170170
}
171171

172-
private getCommitCommand(): Command {
172+
private getCommitCommands(): Command[] {
173173
const config = workspace.getConfiguration('git', Uri.file(this.repository.root));
174174

175175
// Branch protection
@@ -196,7 +196,10 @@ export class CommitCommandsCenter {
196196
l10n.t('Committing Changes to New Branch...');
197197
}
198198

199-
return { command: 'git.commit', title: l10n.t('{0} Commit', icon ?? '$(check)'), tooltip, arguments: [this.repository.sourceControl, null] };
199+
return [
200+
{ command: 'git.commit', title: l10n.t('{0} Commit', icon ?? '$(check)'), tooltip, arguments: [this.repository.sourceControl, null] },
201+
{ command: 'git.commitAmend', title: l10n.t('{0} Commit (Amend)', icon ?? '$(check)'), tooltip, arguments: [this.repository.sourceControl, null] },
202+
];
200203
}
201204

202205
private getPostCommitCommandStringFromSetting(): string | undefined {

0 commit comments

Comments
 (0)