Coder Social home page Coder Social logo

Comments (6)

sebastianfeldmann avatar sebastianfeldmann commented on August 30, 2024 1

It is possible but the implementation must be different.
You have to check the index to get the files "that will change" in the upcoming commit.
This is done "manually" inside some Hooks like the linting hook.
Currently there is no Condition implementation because I haven't figured out a nice way of naming an implementing it without breaking the current FileChanged implementations or copy pasting everything :/

from captainhook.

sebastianfeldmann avatar sebastianfeldmann commented on August 30, 2024 1

I just released version 5.2.0 with the new Staged All and Any conditions that you can use in pre-commit hooks.

from captainhook.

sebastianfeldmann avatar sebastianfeldmann commented on August 30, 2024

You are right, now FileChanged is only executed on post-merge and post-checkout.
This is because FileChanged does not work for any other hook.

The way FileChanged\All and FileChanged\Any are implemented make them only applicable for post-merge and post-checkout hooks.

Both of them are using git diff to detect the changed files. And only post-checkout and post-merge provide the required IDs to get a valid response.

It was "working" with other hooks before but not working at all, the conditions where always false.

from captainhook.

boesing avatar boesing commented on August 30, 2024

So there is no diff in a pre-commit hook?
Thats interesting.

Any suggestion how to receive the diff in a pre-commit hook of those files which are contained within the commit?

Would also know if there is a way to get all changed files in a pre-push hook. Having a diff between HEAD and repository version would be great.

from captainhook.

boesing avatar boesing commented on August 30, 2024

I'll give it a try and if I found a way, I'll contribute back. Thanks so far.

from captainhook.

sebastianfeldmann avatar sebastianfeldmann commented on August 30, 2024

There is a condition specific for pre-commit named FilesStaged\OfType it works similar as FilesChanged\Any. The condition works in a pre-commit hook and will only execute the hook if a file of a given file suffix is staged for commit. I'll add Any and All there today.

from captainhook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.