Skip to content

Mookme does not work with git worktree #127

@conradob

Description

@conradob

As I work on multiple projects simultaneously in a single repository, I use git worktree to manage it.

This will create a new directory for each linked worktree which is linked to the current repository, sharing everything except per-worktree files such as HEAD, index, etc.

Each linked worktree also has a .git file, not a directory, which is causing this error:

$ npx mookme init --only-hook --skip-types-selection

node:fs:1398
  handleErrorFromBinding(ctx);
  ^

Error: ENOTDIR: not a directory, mkdir '/<PROJECT_PATH>/.git/hooks'
    at Object.mkdirSync (node:fs:1398:3)
    at GitToolkit.writeGitHooksFiles (/<PROJECT_PATH>/node_modules/@escape.tech/mookme/dist/utils/git.js:101:26)
    at InitRunner.run (/<PROJECT_PATH>/node_modules/@escape.tech/mookme/dist/runner/init.js:26:29)
    at async Command.<anonymous> (/<PROJECT_PATH>/node_modules/@escape.tech/mookme/dist/commands/init.js:23:9) {
  errno: -20,
  syscall: 'mkdir',
  code: 'ENOTDIR',
  path: '/<PROJECT_PATH>/.git/hooks'
}

The hooks config is in the .hooks dir and works properly when working with main working tree (regular repo checkout).

Is there a way to check if the .git is a file, and if yes, move forward and check for the .hooks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions