Escape-Technologies / mookme

A pre-commit tool designed for monorepos.
MIT License
99 stars 16 forks source link

Fix/pre push strategy #91

Closed LMaxence closed 2 years ago

LMaxence commented 2 years ago

Description

This mr brings basic support for the pre-push strategy. The list of files to use to select hooks to run is computed with the command git rev-list @{push}.. which returns a list of commits. This list is then used to retrieve the list of changed files.

Caveats

The command will surely fail when there are no remote origins. That's why I added a try/catch statement. I'll try to come up with something less flaky.

This should close https://github.com/Escape-Technologies/mookme/issues/81

mhozhynewscorp commented 2 years ago

Great @LMaxence ! How it will behave in case of force-push -- what will be considered as list of changes?

LMaxence commented 2 years ago

Great @LMaxence ! How it will behave in case of force-push -- what will be considered as list of changes?

Hmm the way Mookme is conceived, the files list used to choose the steps to run is independent from the way the git command is involved. Ie, as long as you run a command that will trigger the pre-push pre-commit hook, it will run and use the git rev-list @{push}.. command to list the commits that are in your branch and not in staging.

Regarding the very case of push force, where (I suppose) you would have commits in the remote that are not in your local, and commit in your local that are not in the remote, the commits that are used to build the files list would be the commits that are not in the remote.

I need to make sure it is the case, but my first guess would be that the commits in the remote, but not in the local repository are simply ignored :)

mhozhynewscorp commented 2 years ago

Hey @LMaxence Maybe you have published version from this branch? I can help with tests

LMaxence commented 2 years ago

I just released mookme@2.2.0-beta.5 containing this change :)

mhozhynewscorp commented 2 years ago

Cool, I'll test soon and leave feedback/ thanks!

mhozhynewscorp commented 2 years ago

Hey @LMaxence! Unfortunately, I can only say that nothing has changed. Tested mookme@2.2.0-beta.5