Skip to content

Commit

Permalink
revert change bc args were lost w git similar
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Oct 24, 2022
1 parent b091327 commit f6b1ddb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { localize } from 'vs/nls';
import { TerminalQuickFixMatchResult, ITerminalQuickFixOptions, ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal';
import { TerminalQuickFixMatchResult, ITerminalQuickFixOptions, ITerminalInstance, TerminalQuickFixAction } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ITerminalCommand } from 'vs/workbench/contrib/terminal/common/terminal';
import { IExtensionTerminalQuickFix } from 'vs/platform/terminal/common/terminal';
export const GitCommandLineRegex = /git/;
Expand All @@ -18,8 +18,9 @@ export const GitPushOutputRegex = /git push --set-upstream origin (?<branchName>
// it's safe to assume it's a github pull request if the URL includes `/pull/`
export const GitCreatePrOutputRegex = /remote:\s*(?<link>https:\/\/github\.com\/.+\/.+\/pull\/new\/.+)/;

export function gitSimilar(): IExtensionTerminalQuickFix {
export function gitSimilar(): ITerminalQuickFixOptions {
return {
source: 'builtin',
id: 'Git Similar',
commandLineMatcher: GitCommandLineRegex,
outputMatcher: {
Expand All @@ -29,10 +30,27 @@ export function gitSimilar(): IExtensionTerminalQuickFix {
length: 10
},
exitStatus: false,
extensionIdentifier: 'git',
commandToRun: 'git ${group:fixedCommand}'
getQuickFixes: (matchResult: TerminalQuickFixMatchResult, command: ITerminalCommand) => {
if (!matchResult?.outputMatch) {
return;
}
const actions: TerminalQuickFixAction[] = [];
const results = matchResult.outputMatch[0].split('\n').map(r => r.trim());
for (let i = 1; i < results.length; i++) {
const fixedCommand = results[i];
if (fixedCommand) {
actions.push({
type: 'command',
command: command.command.replace(/git\s+[^\s]+/, `git ${fixedCommand}`),
addNewLine: true
});
}
}
return actions;
}
};
}

export function gitTwoDashes(): ITerminalQuickFixOptions {
return {
source: 'builtin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
for (const quickFix of this._terminalContributionService.quickFixes) {
this.registerCommandFinishedListener(convertToQuickFixOptions(quickFix));
}
this.registerCommandFinishedListener(convertToQuickFixOptions(gitSimilar()));
this.registerCommandFinishedListener(gitSimilar());
this.registerCommandFinishedListener(convertToQuickFixOptions(gitCreatePr()));
this.registerCommandFinishedListener(convertToQuickFixOptions(gitPushSetUpstream()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ suite('QuickFixAddon', () => {
command: 'git status'
}];
setup(() => {
const command = convertToQuickFixOptions(gitSimilar());
const command = gitSimilar();
expectedMap.set(command.commandLineMatcher.toString(), [command]);
quickFixAddon.registerCommandFinishedListener(command);
});
Expand Down Expand Up @@ -220,9 +220,9 @@ suite('QuickFixAddon', () => {
command: 'git push --set-upstream origin test22'
}];
setup(() => {
const command = gitPushSetUpstream();
const command = convertToQuickFixOptions(gitPushSetUpstream());
expectedMap.set(command.commandLineMatcher.toString(), [command]);
quickFixAddon.registerCommandFinishedListener(convertToQuickFixOptions(gitPushSetUpstream()));
quickFixAddon.registerCommandFinishedListener(command);
});
suite('returns undefined when', () => {
test('output does not match', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const allApiProposals = Object.freeze({
contribLabelFormatterWorkspaceTooltip: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribLabelFormatterWorkspaceTooltip.d.ts',
contribMenuBarHome: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribMenuBarHome.d.ts',
contribMergeEditorMenus: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribMergeEditorMenus.d.ts',
contribNotebookStaticPreloads: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribNotebookStaticPreloads.d.ts',
contribRemoteHelp: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribRemoteHelp.d.ts',
contribShareMenu: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribShareMenu.d.ts',
contribTerminalQuickFixes: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribTerminalQuickFixes.d.ts',
Expand Down

0 comments on commit f6b1ddb

Please sign in to comment.