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

Prevent PowerShell 7.3 from breaking tests #951

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DominikJaniec
Copy link

@DominikJaniec DominikJaniec commented Mar 3, 2023

With PowerShell 7.3 the $PSNativeCommandArgumentPassing becomes 'Standard'. It will break a few tests using test-vsts-pr alias. In previous versions of PowerShell, this was set or assumed as 'Legacy', and now it will become 'Windows' on that, and 'Standard' everywhere else.

The 'Legacy', as well as the 'Windows' for certain system-ish executables, makes that:

> echo.exe "magic `"str`" quoted"
magic str quoted

This PR is a solution for an issue risen recently by me: #950

My first commit should break mentioned tests, and it could be reverted once GitHub workflows start running on PowerShell 7.3. Currently, e.g. image used for Windows 2022 has installed version 7.2.10, or the same version is in Ubuntu 22.04.

@DominikJaniec
Copy link
Author

DominikJaniec commented Mar 3, 2023

Strangely, everything passed 😕 Maybe, 7.2 does not support $PSNativeCommandArgumentPassing at all.

Nonetheless, next commit solved problems on my machine 😅

@DominikJaniec DominikJaniec marked this pull request as ready for review March 3, 2023 23:27

if (-not (Test-Path Variable:PSNativeCommandArgumentPassing) `
-or $PSNativeCommandArgumentPassing -eq 'Legacy') {
$value = $value.Replace("`"", "\`"")
Copy link
Author

Choose a reason for hiding this comment

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

I've debated with oneself, if explicit version should be used here:

Suggested change
$value = $value.Replace("`"", "\`"")
$value = "!f() { exec vsts code pr \`"`$`@\`"; }; f"

@DominikJaniec
Copy link
Author

I hope, this will be useful, once workflows would run on PowerShell 7.3

@zhilbug
Copy link

zhilbug commented May 12, 2023

Any update on this? I'm missing my posh-git!

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.

None yet

2 participants