Comments (15)
Of course, My config is very simple like:
# lefthook.yml
remotes:
- git_url: http://git_address/tools/lefthook-config
configs:
- remote_main.yml
# remote_main.yml
source_dir: ./
prepare-commit-msg:
scripts:
"remote-script.sh":
runner: bash
from lefthook.
Hey, The log I used master version with refetch option is as follows:
+ call_lefthook run prepare-commit-msg .git/COMMIT_EDITMSG
+ test -n ''
+ lefthook.exe -h
+ lefthook.exe run prepare-commit-msg .git/COMMIT_EDITMSG
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] err: <nil>
│ [lefthook] out: D:/source/IA-Git/main
│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] err: <nil>
│ [lefthook] out: .git/hooks
│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] err: <nil>
│ [lefthook] out: .git/info
│ [lefthook] cmd: [git rev-parse --git-dir]
│ [lefthook] err: <nil>
│ [lefthook] out: .git
│ [lefthook] cmd: [git hash-object -t tree /dev/null]
│ [lefthook] err: <nil>
│ [lefthook] out: 4b825dc642cb6eb9a060e54bf8d69288fbee4904
│ Merging remote config: http://git_address/tools/lefthook-config: .git\info\lefthook-remotes\lefthook-config\remote_main.yml
╭───────────────────────────────────────────────╮
│ 🥊 lefthook v1.6.15 hook: prepare-commit-msg │
╰───────────────────────────────────────────────╯
│ Updating remote config repository: .git\info\lefthook-remotes\lefthook-config
│ [lefthook] cmd: [git -C .git\info\lefthook-remotes\lefthook-config pull --quiet]
│ [lefthook] dir: D:/source/MyProject/main
│ [lefthook] err: <nil>
│ [lefthook] out:
│ Searching config in:D:/source/MyProject/main
│ Merging remote config: http://git_address/tools/lefthook-config: .git\info\lefthook-remotes\lefthook-config\remote_main.yml
sync hooks: ❌
⚠️ There was a problem with synchronizing git hooks. Run 'lefthook install' manually.
Error: could not add the hook: open D:\source\MyProject\main\.git\hooks\prepare-commit-msg: Access is denied.
┃ remote-script.sh ❯
My config was like this:
# lefthook.yml
remotes:
- git_url: http://git_address/tools/lefthook-config
refetch: true
configs:
- remote_main.yml
from lefthook.
Hey, thank you for your reply. Although I am not familiar with Go and Bash, I would like to share my approach. I don't think updating prepare-commit-msg scripts during execution is necessary in this "refetch" case. Would it be feasible to update only remote scripts in the ./.git/info directory instead?
from lefthook.
@SirNoSir , could you please check the unpublished version (using the same go install ...
command as before). I've skipped installing the hooks if nothing is touched in the main config. So, this should fix the "Access is denied" error.
from lefthook.
Hey! I found a place where the error happens however lefthook does not log the error, so it's hard to say what was the actual problem. Does it fail the same way if you don't use refetch: true
and manually run lefthook install && lefthook run prepare-commit-msg
?
from lefthook.
whether I set refetch true or false, It works well when i run lefthook install && lefthook run prepare-commit-msg
. Any ideas?
lefthook install && lefthook run prepare-commit-msg
sync hooks: ✔️ (prepare-commit-msg)
╭───────────────────────────────────────────────╮
│ 🥊 lefthook v1.6.15 hook: prepare-commit-msg │
╰───────────────────────────────────────────────╯
┃ remote-script.sh ❯
d in %PATH%
────────────────────────────────────
summary: (done in 0.06 seconds)
🥊 remote-script.sh
from lefthook.
So, it only fails if you run lefthook implicitly with git commit ...
command, right?
Could you please check these steps:
- remove
refetch: true
from the remotes - remove
lefthook install
from the rc file git add -A && git commit
Since you've touched the lefthook.yml
file lefthook should try to overwrite the hooks and display sync hooks: ✔️ (prepare-commit-msg)
. I just wonder if it fails to overwrite the hooks or the problem is related to fetching/merging the configs after fetching the remotes.
from lefthook.
These are the details of my operations, I hope it can help.
- When I followed the steps above, the hooks sync failed. However, it still ran my script anyway.
- After that, I checked ./.git/hooks/ in my project, and the prepare-commit-msg file was removed.
- The next time I ran git commit, lefthook was not triggered since the hooks file was not present.
git add -A && git commit
warning: in the working copy of 'lefthook.yml', LF will be replaced by CRLF the next time Git touches it
╭───────────────────────────────────────────────╮
│ 🥊 lefthook v1.6.15 hook: prepare-commit-msg │
╰───────────────────────────────────────────────╯
sync hooks: ❌
⚠️ There was a problem with synchronizing git hooks.
Run 'lefthook install' manually.
┃ remote-script.sh ❯
git add -A && git commit
Aborting commit due to empty commit message.
from lefthook.
Ok, I will try to prepare a fix that at least displays the error.
I assume that this may be related to configuration merging and prepare-commig-msg
file may be dropped while being installed.
Could you share your lefthook.yml
hooks and the remote config (just the basic structure without the real commands/scripts)?
from lefthook.
Thank you. I could not reproduce the error but I will release a new version that prints the error so we can have more context on what is the reason.
from lefthook.
If you have a chance to install lefthook with go install github.com/evilmartians/lefthook@latest
, could you try the lefthook version that is currently in master?
from lefthook.
Ok, I see that the problem is related to opening a file which is probably being executed at the moment of calling the script. I will need to think out a solution for this issue 🤔
from lefthook.
Yes, I think so, I will try to implement this approach 👍
from lefthook.
Great! I just tested the latest version. It ran perfectly and correctly, executed the script I had just modified on Git. Thank you for your help! 😄
from lefthook.
Nice! I will prepare the release later this week 👍
from lefthook.
Related Issues (20)
- Include git output when commands fail HOT 1
- npm: Not working with bun without node HOT 7
- lefthook.yml is automatically added when using my library HOT 4
- `stage_fixed`: `Couldn't stage fixed files:fork/exec C:\Program Files\Git\mingw64\bin\git.exe: The filename or extension is too long.` on Windows HOT 2
- Pass `--all-files` flag to the command being run during the hook HOT 4
- Performance for `npm` could be even more faster? HOT 4
- submit logo to simple-icon HOT 1
- Error: Cannot find module 'lefthook-linux-x64/bin/lefthook' on git commit after updating npm dependency to 1.6.10 HOT 8
- "no matching staged files" error when I ran "pre-commit" manually HOT 2
- `exclude` configuration as array HOT 1
- Error message when lefthook is older could include more info HOT 1
- Prepackaged PHP Composer
- It was detected as a virus. HOT 3
- lefthook fails git command when run with GIT_TRACE=1 HOT 1
- Option to redirect standard input to `/dev/null` HOT 5
- fetch new scripts automatically when remote scripts changed HOT 1
- Paths with brackets parsed incorrectly in Windows environment HOT 3
- 1.6.16 not available in apt/rpm repos HOT 1
- Bug: Global extend options will take precedence over local options HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lefthook.