Closed giggio closed 3 months ago
Thats true, the deeper problem here is that the installer uses the Gitconfig to store some of its persistent settings, it will always make sure that the variables it stores are consistent together.
I think the variables under concern to not change is: githooks.installDir
, the other githooks.runner
is internal and githooks.dialog
(never used just a handy shortcut, for users)
Maybe we can say we dont change githooks.installDir
basically reading it with env. values substitute but writting it unexpanded. However githooks.runner
still changes by the installation. Having a flag saying no do not change certain variables is kind of crude...
https://github.com/gabyx/Githooks/pull/144
What I'm doing now is bypassing the installer altogether and doing my own installation.
I wrote a script that downloads the latest release, unpacks it to ~/.githooks/bin
, then I run ~/.githooks/bin/cli update
. It seems to work fine like that.
It still changes 2 things in my git config: githooks.cloneUrl
and cloneBranch
. It is adding a tab before these configs (I use 2 spaces), so I guess it is trying to update them.
I'd like it didn't change anything, either when installing or updating.
Generally all githooks.*
settings are updated during cli update
(it runs the installer).
https://stackoverflow.com/a/42401876/293195
Maybe your suggestion is still somehow possible. I was thinking that the auto udpate feature makes everything quite complicated, but is really handy and shitty (nixos) at the same time. However, what should happen on an autoupdate (it sets Git config values potentially etc... also introducing maybe new values), so having an cli installer --no-gitconfig-changes
introduces a whole lot of complication, in the sense how is it guaranteed that the install is correct or works afterwards.
Could we outsource the githooks.*
config values to another file ~/.githooks/.gitconfig
which is used instead? Also quite hard to implement. Somewhere in some file you need to change things. If that file is different (formatting) then what you have in your template repo (dotfiles) its always an issue... igf its a yaml file or some other format does not matter
I would need to think more on that.
Having its own config file would be nice, but I'd also like to add it to my dotfiles config, so the problem would remain. What you could do is update only when needed. In my scenario nothing had changed, cloneurl and clonebranch remained the same. Check if the value is not equal, and only then update. Also, you could update the config file without invoking git, after all, it is just an ini file.
Fixed by #160.
The version v3 (not yet out) has an option in the install --git-config-no-abs-path
which will default to non absolute paths (githooks.runner
, githooks.dialog
, alias.hooks
).
Version 3 will also have build support for package managers, so when installed with e.g. Nix or any other package-manager we disable updateing functionality (in version 3 updates are never automatically dispatched anymore)
and we also do not use githooks.runner
anymore when packaged for a package-manager and the run-wrapper wil search for githooks-runner
which needs to be in the path (also when using --git-config-no-abs-path
)
The install dir githooks.installDir
is however not yet affected and is still in the config with absolute path.
PR #144 should still be tackled to provide you this feature though. Will get merged whe v3 is ready.
@gabyx I just tried the new installer, but there is no option for --git-config-no-abs-path
.
Running it with githooks-cli installer --non-interactive
changed may .gitconfig
:
diff --git a/home/.gitconfig b/home/.gitconfig
index 588c57d..d1bd06d 100644
--- a/home/.gitconfig
+++ b/home/.gitconfig
@@ -65,7 +65,7 @@
squash = "!f() { git reset --hard $1; git merge --squash HEAD@{1}; git commit; }; f"
continue = "-c core.editor=true rebase --continue"
a = add :/
- hooks = !\"githooks-cli\"
+ hooks = !\"githooks-cli\"
parse-env-vars = "!f() { \
awk '{ \
finalstr = $0; \
@@ -119,10 +119,11 @@
[pack]
windowMemory = 0
[githooks]
- cloneUrl = https://github.com/gabyx/githooks.git
- cloneBranch = main
- installMode = manual
- pathForUseCoreHooksPath = /home/giggio/.githooks/templates/hooks
- runner = githooks-runner
- dialog = githooks-dialog
- maintainedHooks = all
+ cloneUrl = https://github.com/gabyx/githooks.git
+ cloneBranch = main
+ installMode = manual
+ pathForUseCoreHooksPath = /home/giggio/.githooks/templates/hooks
+ runner = githooks-runner
+ dialog = githooks-dialog
+ maintainedHooks = all
+ installDir = /home/giggio/.githooks
I believe this issue should be reopened.
I use dotfiles to configure my environment, when the installer changes the values in .gitconfig it creates unwanted changes.
It would be nice to have an option to disable changes to .gitconfig, and only setup the application files in the expected directory.
The installer could read .gitconfig to find
githooks.installDir
, and if not found, use the default location of$HOME/.githooks
.