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

Quote tab completion items with PS special chars. #413

Merged
merged 4 commits into from
Feb 14, 2017

Conversation

rkeithhill
Copy link
Collaborator

Fix #293

@rkeithhill
Copy link
Collaborator Author

If we merge this for 0.7.0, don't forget to update CHANGELOG.md.

@rkeithhill rkeithhill requested a review from dahlbyk February 13, 2017 16:07
Copy link
Owner

@dahlbyk dahlbyk left a comment

Choose a reason for hiding this comment

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

Off to a good start! Seems close enough to include in this next release.

@@ -51,6 +51,15 @@ catch {
Write-Debug "Search for 'flow' in 'git help' output failed with error: $_"
}

filter quoteStringWithSpecialChars {
if ($_ -and ($_ -match '\s+|#|@|\$|;|\{|\}|\(|\)')) {
"'" + $_ + "'"
Copy link
Owner

Choose a reason for hiding this comment

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

  1. Why not "'$_'"?
  2. We should also handle values that include '.

@@ -51,6 +51,15 @@ catch {
Write-Debug "Search for 'flow' in 'git help' output failed with error: $_"
}

filter quoteStringWithSpecialChars {
if ($_ -and ($_ -match '\s+|#|@|\$|;|\{|\}|\(|\)')) {
Copy link
Owner

Choose a reason for hiding this comment

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

Missing ,

$result | Should BeExactly $fileName
}
}

Context 'PowerShell Special Chars Tests' {
BeforeAll {
Copy link
Owner

Choose a reason for hiding this comment

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

This is bound to be a pretty common pattern. Is it possible to write a Pester helper that would encapsulate a BeforeAll/AfterAll pairing that initializes and cleans up a Git repo, with its path left in $repoPath? Something like:

Context 'Awesome test' {
    TempRepo {
        # Set up the repo
    }
    It 'Uses $repoPath' {
        # ...
    }
}

@dahlbyk dahlbyk added this to the v0.7 milestone Feb 13, 2017
I don't know that Pester will support a user-defined construct to encapuslate BeforeAll/AfterAll.  But I did pull the guts out into shared functions.
@rkeithhill
Copy link
Collaborator Author

I think I've addressed all of the issues except the last one the Pester helper. That said, I did move common code into reusable functions (in Shared.ps1).

Copy link
Collaborator Author

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

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

👍

@dahlbyk dahlbyk merged commit 76ecd00 into master Feb 14, 2017
@dahlbyk dahlbyk deleted the rkeithhill/is293-tab-complete-special-chars branch February 14, 2017 06:06
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.

3 participants