Lakshmikanth2001 / GitHooks

Git Hooks VS-Code Extension
https://marketplace.visualstudio.com/items?itemName=lakshmikanthayyadevara.githooks
Other
7 stars 2 forks source link

Absolute path is used in the hooksDirectory setting in settings.json #12

Closed AquilaSands closed 11 months ago

AquilaSands commented 1 year ago

The hooksDirectory setting is using an absolute path in the workspace settings.json and as this file is normally committed to the repo it will cause a lot of unnecessary changes to this file for teams of devs or if you work across different devices e.g. Mac and Win.

Lakshmikanth2001 commented 1 year ago

yes this issue was previously addressed in #10 , I need to search for a function that can read relative path in node can you suggest one 😅

Lakshmikanth2001 commented 1 year ago

Thanks @AquilaSands. In the latest release (i.e 91fd44859190d4228f7262a2020a0f4eae6bad1c v1.3.1), I figured out that we can use Node's path.resolve to get the relative directory. I have extended the support to input a relative path in the GitHooks.HooksDirectory settings. Please test it and give your valuable feedback. feel free to close the issue if every thing works for you thank you

mpao commented 11 months ago

Hi there, there could have been another solution with

"GitHooks.hooksDirectory": "${workspaceFolder}/.git/hooks"

but on every window reload, the plugin overwrites this solution with the absolute path. Now relative path works fine, not sure what is the better approach :)

Lakshmikanth2001 commented 11 months ago

@mpao In my Visual Studio Code extension, I've added code to handle relative directories up to two levels (. and ..). This is because the extension receives the expanded output of ${workspaceFolder}/.git/hooks, not the raw string. As a result, I lose the actual value entered by the user. Therefore, I encourage users to use relative directories to avoid this issue.

let me know if i can close this issue

mpao commented 11 months ago

The issue is in the project settings.json file.

If you told me to use a relative path, I think I should use ../.git/hooks since the setting is the project's .vscode directory. Well, this is reported as wrong and overrided with the absolute path.

.git/hooks works great instead. I'm a new user of VSC and maybe I don't quite understand his behaviors, but seems than the issue is about documentation

Lakshmikanth2001 commented 11 months ago

ok i am closing this issue then as the relative path is working fine, thank you for your comments 😀