Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert default command template values into ShellQuotedString format #4433

Merged
merged 4 commits into from
Dec 19, 2024

Conversation

danegsta
Copy link
Contributor

If a task command template has the default value, this attempts to parse it and convert into a ShellQuotedString format so that VSCode will perform appropriate argument escaping for the selected shell. The current logic will only run if a task is configured with the default value as the current parsing logic assumes certain conditions that may not be true for a user customized value.

This should resolve #4291.

@danegsta danegsta requested a review from a team as a code owner December 18, 2024 20:50
bwateratmsft
bwateratmsft previously approved these changes Dec 18, 2024
Copy link
Collaborator

@bwateratmsft bwateratmsft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced offline, this needs some adjustment:

if (tagRegex.test(terminalCommand.command)) {
const absFilePath: string = path.join(rootFolder.uri.fsPath, dockerFileItem.relativeFilePath);
const dockerFileKey = `buildTag_${absFilePath}`;
const prevImageName: string | undefined = ext.context.workspaceState.get(dockerFileKey);
// Get imageName based previous entries, else on name of subfolder containing the Dockerfile
const suggestedImageName = prevImageName || getValidImageNameFromPath(dockerFileItem.absoluteFolderPath, 'latest');
// Temporary work-around for vscode bug where valueSelection can be messed up if a quick pick is followed by a showInputBox
await delay(500);
addImageTaggingTelemetry(context, suggestedImageName, '.before');
const imageName: string = await getTagFromUserInput(context, suggestedImageName);
addImageTaggingTelemetry(context, imageName, '.after');
await ext.context.workspaceState.update(dockerFileKey, imageName);
terminalCommand.command = terminalCommand.command.replace(tagRegex, imageName);
}

bwateratmsft
bwateratmsft previously approved these changes Dec 19, 2024
@danegsta danegsta merged commit 4799004 into main Dec 19, 2024
2 checks passed
@danegsta danegsta deleted the dev/danegsta/taskShellQuoting branch December 19, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compose Up command escaping issue on folder with spaces
2 participants