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

Add tab expansion support for git restore / switch #702

Merged
merged 3 commits into from
Oct 13, 2019

Conversation

rkeithhill
Copy link
Collaborator

Fix #691

"^restore.* -s\s*(?<ref>\S*)$" {
gitBranches $matches['ref'] $true
gitTags $matches['ref']
break
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder if more of these switch cases should be using break. Once we've found a "match" do we need to continue with every subsequent regex match?

Copy link

@pinkfloydx33 pinkfloydx33 Sep 24, 2019

Choose a reason for hiding this comment

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

I was actually running into issues with this case myself and ended up matching --staged somehow, and kinda gave up and forgot to look back at it. That said, I think this looks semi-correct. I think this will match "-S" (which is the short-form of staged) followed by anything since we aren't using a case-sensitive match

Choose a reason for hiding this comment

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

@rkeithhill re: break ... when working on my version of this as well as #696 I realized that the fall through would end up matching some of the later cases per the regex, but then return nothing based on the inner function calls. (lots of Write-Host debugging :-p) and was going to suggest we throw in breaks. With that said, I swear I encountered at least one instance where the fall-through actually caught an edge-case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I swear I encountered at least one instance where the fall-through actually caught an edge-case.

That's why I'm nervous about throwing in break everywhere. But in this new case, it should break IMO.

RE the above code matching on -S, good catch. I'll make this regex be case-sensitive.

@rkeithhill
Copy link
Collaborator Author

@pinkfloydx33 Updated. Can you take another peek?

@rkeithhill rkeithhill force-pushed the rkeithhill/add-switch-restore-tab-completions branch from a605032 to 21857a4 Compare October 13, 2019 18:54
@rkeithhill rkeithhill merged commit e4753e2 into master Oct 13, 2019
@rkeithhill rkeithhill deleted the rkeithhill/add-switch-restore-tab-completions branch October 13, 2019 18:59
@rkeithhill
Copy link
Collaborator Author

@pinkfloydx33 I'm going to merge this. Can you pull master and try it out. If you find any issues, we can fix them before the final release.

conflict = 'merge diff3'
source = {
param($ref)
gitBranches $matches['ref'] $true
Copy link
Owner

Choose a reason for hiding this comment

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

I don't always review code, but when I do it's six months later. 💪

Did you mean to use $ref here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, good catch. I'll submit a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support completion for new git switch and git restore commands
3 participants