Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no pre-commit file is created in the .git/hook directory #105

Open
faboulaws opened this issue Jan 26, 2023 · 6 comments
Open

no pre-commit file is created in the .git/hook directory #105

faboulaws opened this issue Jan 26, 2023 · 6 comments
Labels
question Further information is requested

Comments

@faboulaws
Copy link

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:

  1. Create file
#!/bin/bash

npx mookme run --type pre-commit --args "$1"
  1. Add permission
chmod +x .git/hooks/pre-commit

Any idea why the file was not created?

@LMaxence
Copy link
Member

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 ?

@LMaxence LMaxence added the question Further information is requested label Jan 29, 2023
@braincore
Copy link

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.

@LMaxence
Copy link
Member

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 ?

@braincore
Copy link

@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!

@uncledru
Copy link

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).

@muhammedbasilsk
Copy link

muhammedbasilsk commented Jan 15, 2024

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).

@uncledru
Your approach worked. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants