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

Failure to execute script hooks when path to repository contains whitespace #819

Closed
bradchoate opened this issue Sep 19, 2024 · 3 comments · Fixed by #823
Closed

Failure to execute script hooks when path to repository contains whitespace #819

bradchoate opened this issue Sep 19, 2024 · 3 comments · Fixed by #823
Labels
bug Something isn't working

Comments

@bradchoate
Copy link

🔧 Summary

Similar issue to #403. A project directory containing a space causes issues.

Lefthook version

1.7.15 5ad1281

Steps to reproduce

  1. $ mkdir "my project"
  2. $ cd "my project"
  3. $ git init
  4. $ npm install @evilmartians/lefthook
  5. $ npx lefthook install
  6. $ echo "# hello" > readme.md
  7. $ git add readme.md
  8. Create a lefthook.yml file that declares:
prepare-commit-msg:
    scripts:
        "my-script.sh":
            runner: bash
  1. Create a .lefthook/prepare-commit-msg/my-script.sh (and chmod +x):
#!/bin/bash
echo "prepare-commit-msg script ran"
  1. $ git commit

Expected results

Commit loads editor and on completion, prepare-commit-msg hook echoes "prepare-commit-msg script ran".

Actual results

Git commit command fails as the prepare-commit-msg hook fails to execute, with the message:

|  my-script.sh >

bash: /path/to/my: No such file or directory

Possible Solution

The script to execute via the runner should be quoted.

Logs / Screenshots

@bradchoate bradchoate added the bug Something isn't working label Sep 19, 2024
@mrexox
Copy link
Member

mrexox commented Sep 20, 2024

Hey! Thank you for creating this issue. What's your OS? Is it Windows?

@bradchoate
Copy link
Author

Sorry-- should have included that: macOS (Sonoma).

@bradchoate
Copy link
Author

Can confirm this fixes the issue. Thanks for the quick update / release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants