rycus86 / githooks

Githooks: per-repo and global Git hooks with version control
MIT License
382 stars 20 forks source link

Install folder customization #40

Closed gabyx closed 5 years ago

gabyx commented 5 years ago

It would be really nice to take up again the install folder again, since it would make usage of the following scenario much easier, as well as it is more powerful:

When I install githooks on Windows it will be installed to C:/Users/.../.githooks. The git config ins Ubuntu Subsystem /root/.gitconfig would then look something like:

[githooks]        
        failOnNonExistingSharedHooks = true
        python = /.../.../AppData/Roaming/.../python/python.exe # my custom stuff...
[alias]
        hooks = !/mnt/c/Users/gabriel.nuetzi/.githooks/bin/githooks

When you wanna do some git manipulation in windows ubuntu subystem. You end up reinstalling shared hooks somewhere else /root/.githooks/.... This is quite cumbersome. If githooks would know the installation directory (extract from alias), using githooks from bash in the subsystem behaves identically as on windows git-bash.exe.

It would be nice, to have the already proposed set_install_dir in place and replace all occurances ~/.githooks with a proper install dir. and also provide a --prefix option in install.sh.

rycus86 commented 5 years ago

So the problem here is that the user in Git Bash is different than in WSL? That sounds like a general configuration issue, not specific to Githooks. I'm not against adding an extra flag to the install script, it's just cumbersome and one more flag to confuse users.

rycus86 commented 5 years ago

If githooks would know the installation directory (extract from alias), using githooks from bash in the subsystem behaves identically as on windows git-bash.exe.

That sounds like relying on a side effect. If we do this, we should set a global configuration value that points to the install dir (which I thought we have already), and use that. Is the problem here that the global Git config file will be a different one? If yes, do you have to set up all your Git config twice? Like committer name, email, etc.

gabyx commented 5 years ago

Yes the config files need to be setup also in WSL under root/.gitconfig If I wanna use the same alias.hooks path, it wont work properly since the install directory is different in the subsystem and windows install...

If we do this, we should set a global configuration value that points to the install dir (which I thought we have already)

Where is this variable? We dont have this, I made once some changes in this direction, but during review we dropped this...

gabyx commented 5 years ago

I would make a PR with a setting

[githooks]
 installDir = "...."

and --prefix for the installation. Would that be of value?

rycus86 commented 5 years ago

We can talk about it. Is the problem here not that the ~/.gitconfig file will be different? Because in that case we can't really set a config value for both places.

gabyx commented 5 years ago

Jeah, but when I manually copy the gitconfig to the subsystem location /root/.gitconfig -> I can manually replace the installDir = C:/User/..../.githooks to something installDir = /mnt/c/Users/..../.githooks and it should work :) of course the templateDir and alias.hooks needs replacements too... That is the users part of course... has nothing to do with githooks.

rycus86 commented 5 years ago

Right... Not exactly good UX. :) If you have manual steps, you could just replace bits manually too.

Is the problem that we don't have anything in the global config about where Githooks is? What functionality needs the install directory by the way?

gabyx commented 5 years ago

;-)

Is the problem that we don't have anything in the global config about where Githooks is?

Correct, thats the thing, githooks uses lots of hardcoded ~/... paths which is not exactly what should be done when we would have a global install directory. All it needs is

  1. replace all "~" path with correct installDirectory paths. (place that in the global config)
  2. provide a install.sh --prefix <path> where the .githooks folder gets installed
rycus86 commented 5 years ago

~ is correct. ;) The Git Bash / WSL setup sounds like not super compatible, nothing really specific to Githooks.

If that's all that's missing for you, then yeah please open a PR then we'll get it in. :+1:

gabyx commented 5 years ago

Jeah I think thats all thats missing. :-) I will have a look when I have time. thanks :-)

rycus86 commented 5 years ago

Great, thank you!

gabyx commented 5 years ago

~ is correct. Of course, I would also leave this as the default install directory :-).