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

Building Regex for file path inside ./.git/hook in vscode extension #5

Closed
Lakshmikanth2001 opened this issue Mar 20, 2023 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Lakshmikanth2001
Copy link
Owner

  • Current Regex just verifies whether .git and hook both are present in path or not which not an accurate way to tell whether file belongs to ./git/hook this path
"editor/title": [
				{
					"when": "resourcePath =~ /(?=.*\\.git)(?=.*hooks).*/",
					"command": "git-hooks.runCurrentHook",
					"group": "navigation"
				}
			]

Updated this regex to view the runButton only inside .git/hooks directory

@Lakshmikanth2001 Lakshmikanth2001 added bug Something isn't working good first issue Good for newcomers labels Mar 20, 2023
@9AMTech
Copy link
Contributor

9AMTech commented Mar 20, 2023

I was trying to find the file for this so I can do the whole pull request thing. (New to open source, sorry.) I couldn't find the relevant code, but try this regex.

(\/git\/hook\/)

@Lakshmikanth2001
Copy link
Owner Author

Lakshmikanth2001 commented Mar 20, 2023

Thank You for your suggestion based on your regex pattern i have build an another regex for this logic

/(\/\.git\/hooks\/)/ this is simple you can got to package.json and edit editor/title when clause and submit a pull

request, i hope this will be your first pull request to break the ice 😀

This Regex builder website can help you

@9AMTech
Copy link
Contributor

9AMTech commented Mar 20, 2023

Thanks for the opportunity! I love using regexr. It's the best tool for issues like this! I submitted the pull request w/ the correct regex.

@Lakshmikanth2001
Copy link
Owner Author

"when": "resourcePath =~ /(\/\\.git\/hooks\/)/ || resourcePath =~ /(\\.git\\\\hooks\\\\)/",

Final regex which was working for both mac and windows is this one thank you for your contribution

i want to share small code snippet which can help in in budling regex inside string ( node.js env )

var regexParten = /(git\\hooks\\)/
regexParten.source 
'(\\\\.git\\\\hooks\\\\)'

it help when your regex contains string escape characters ,

Thank You for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants