Escape-Technologies / mookme

A pre-commit tool designed for monorepos.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pre-push hook working intermittently

eamon-sharifi-kf opened this issue Β· comments

Hi there πŸ‘‹πŸΌ

I've been looking to get git hooks working on my monorepos for some time now and have come across your package. It seems to be exactly what I'm looking for so I've tested out adding to my repo.

The pre-commit hooks are working a dream but I'm having some trouble with pre-push. The pre-push hook has only successfully run once or twice, then the rest of the time it's like no hook is there at all. There are definitely changes to the project in question as the pre-commit hooks are running before I push.

This is what my pre-push.json file looks like:

{
  "steps": [
    {
      "name": "Testing",
      "command": "npm run test"
    }
  ]
}

I believe I've initiated the project correctly because I selected all hooks in the CLI process and I have this pre-push file in my .git/hooks folder (there's also a pre-push.sample):

#!/bin/bash
npx mookme run --type pre-push --args "$1"

Is this is a known issue? Anything you can do to help would be greatly appreciated.

Thanks and keep up the good work! ✌🏼

I have the same issue, this approach is the best, but the pre-push doesnt work for me.
I want to use pre-commit for linting, type-checking , format....
and pre-push for unit-testing .

Running into the same issue in 2.4.0 - Downgrading to 2.1.1 fixes this issue for me.

Hello guys, really happy you are getting into using Mookme :)

I'm the only maintainer of the lib and my work life is pretty demanding right now. I'll do my best to circle back on this issue by the end of the week. By then, feel free to provide a bug fix, the pre-push hook is pretty picky so I would not be surprised that there are some bugs since it involves a tremendous amount of edge cases.

Also, would you mind providing me with the content of your pre-push script file please ? The file should be located at <repo-root>/.git/hooks/pre-push

Thank you @LMaxence! My pre-push script looks like this:

#!/bin/bash
npx mookme run --type pre-push --args "$1"

Hello :)

I've been messing around with the pre-push hook, but as I mentioned it is subject to many edge cases. It would help me a lot delivering a fix in much shorter notice if you could provide me with a reproducible scenario. The ideal form this would take would be a repository featuring a list of reproduction instructions (what files to edit, git add, files to create, stuff to commit before creation).

Some details below about the pre-push hook, so that you understand better what would help make this work fine:

Under the hood, there is always a single parameter that leads to a hook being triggered or not in mookme: The list of changed files.

In the case of a pre-commit hook for instance, it's easy, there are explicit git commands leading to this list.

However for the pre-push case, it's much harder to provide a reliable heuristic. We need to identify the set of files part of the diff between the remote branch and the local branch. I'm not gonna lie, when there is no remote branch for instance, it's a mess.

Thanks @LMaxence. I can try to put something reproducible together this weekend.

Some extra context here though - My team is using Mookme inside of a monorepo using yarn workspaces. The relevant parts of our file structure are listed below:

  • .git
  • .hooks
  • packages
    • package-a
      • src
      • package.json
    • package-b
    • package-c
    • package-d
    • ...
  • applications
    • application-a
    • application-b
  • .mookme.json
  • package.json

Hey yall! I believe I have a fix for this: #118