mookme
mookme copied to clipboard
no pre-commit file is created in the .git/hook directory
I have followed the steps in at https://mookme.org/. However, the script was not triggered when committing files. I had to look through the code, and created the pre-commit file manually:
- Create file
#!/bin/bash
npx mookme run --type pre-commit --args "$1"
- Add permission
chmod +x .git/hooks/pre-commit
Any idea why the file was not created?
Hello !
First of all, I think it is the first time I see you around on the repository, so thanks for using Mookme :)
I tried the setup script as provided in the documentation, and things went fine to me:
# Initialize a repo
mkdir test
cd test
git init
npm init -y
# Install mookme and init
npm install -D @escape.tech/mookme
npx mookme init # Select the pre-commit step in the prompter
cat ./.git/hooks/pre-commit # should be fine
My very first guess is that you did not run npx mookme init. If it weren't the case, could you provide me with some informations on you rplatform please ? Like an OS type, or a script I could execute ?
I just tried mookme for the first time and ran into the same issue. Here's the output from the init step:
The following configuration will be written into `/path/to/repo/.mookme.json`:
{
"addedBehavior": "exit"
}
The follwowing git hooks will be created:
/path/to/repo/.git/hooks/prepare-commit-msg
/path/to/repo/.git/hooks/commit-msg
The following entries will be added into `/path/to/repo/.gitignore`:
.prepare-commit-msg.local.json
.commit-msg.local.json
? Do you confirm ? Yes
Writing configuration...
Done.
Initializing hooks folders...
An example hook has been written in `./.hooks/pre-commit.json`
Writing Git hooks files
- /path/to/repo/.git/hooks/prepare-commit-msg
Hook prepare-commit-msg does not exist, creating file...
- /path/to/repo/.git/hooks/commit-msg
Hook commit-msg does not exist, creating file...
Writing `.gitignore files`
Your hooks are configured.
Despite what the logs claim, only commit-msg was generated.
Hey @braincore, I'm just finishing a business trip this week, and won't have time to look into that matter by then end of the week.
I'll do my best to circle back at you next week when I take a deeper look into why not every file is created.
If ever time is an issue for you, feel free to look around and open a pr, I will find time to have it reviewed :)
Still, it would help me a lot to grab more context to reproduce the problem, could you provide me with some informations on your platform please ? Like an OS type, or a script I could execute ?
@LMaxence Looking at the output I provided earlier, I'm guessing this was a case of user (me) error. The output claims to be creating prepare-commit-msg and commit-msg, but I had meant to create pre-commit so I was likely looking for the wrong file.
FWIW, this was on a Ubuntu 22.04 machine running the initial setup npx mookme init.
I just tried a couple permutations to reproduce the error in a new folder (git init && npx mookme init) and wasn't able to either.
Everything else in my setup went smoothly so thank you for creating this!
I ran into this issue using the warp terminal. After going through the source - I was able to run
npx mookme init --added-behaviour "exit" --only-hook --skip-types-selection --yes
Which uses the hooks in .hooks/ and creates the corresponding file in .git/hooks. Seems selection is broken in warp (configured with zsh).
I ran into this issue using the warp terminal. After going through the source - I was able to run
npx mookme init --added-behaviour "exit" --only-hook --skip-types-selection --yesWhich uses the hooks in
.hooks/and creates the corresponding file in.git/hooks. Seems selection is broken in warp (configured with zsh).
@uncledru Your approach worked. Thank you