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

Getting the information of what is to be pushed in pre-push hook #1908

Closed
Jonas-Visma opened this issue May 12, 2021 · 6 comments
Closed

Getting the information of what is to be pushed in pre-push hook #1908

Jonas-Visma opened this issue May 12, 2021 · 6 comments
Labels

Comments

@Jonas-Visma
Copy link

As mentioned in #1410, some of the information given to pre-push from git is missing. Unlike #1410 I am wondering whether it is possible to get the information about every single commit about to be pushed?

I suspect that this is currently not possible, based on #693 and the function _pre_push_ns. Which seems to discard this information.

Is this a feature that would be possible to incorporate in the design of pre-commit? Or is there a work around I am not seeing? The work around should preferably still utilize this awesome framework so the pre-push wouldn't have to be manually setup.

@asottile
Copy link
Member

yeah it's ~generally not possible within the framework which makes some (potentially incorrect) assumptions that you're pushing the checked out commit -- as far as I can tell it has always been this way 🤷

@Jonas-Visma
Copy link
Author

Thank you for your response.

For my use case that is too bad, but there is probably a good reason for it. Either way, would you mind me having a look to see if I can add this feature without breaking or altering the design? If you believe it to be possible, of course.

@asottile
Copy link
Member

I don't think it's possible within the framework, but feel free to have a look

@Jonas-Visma
Copy link
Author

Alright. I will have a gander and make a comment my findings.

@kim-groenborg-nielsen
Copy link

The issue that @Jonas-Visma and I are trying to solve, is to get the stdin data passed on to the plugin so we can validate branch and tag names. Either by getting data via stdin or via environment variables.
Currently, it does not matter for us if the pre-push plugin runs in other branches than the current one.

So I have an easy solution to our problem, which only involves modifying hook_impl.py, so the pre-push plugins are called once for each branch to be pushed.
Could that kind of solution be accepted by you?

@asottile
Copy link
Member

not really, that will trigger hooks on unrelated code (and many times)

you could use a legacy hook which would receive the full stdin, but that'd be outside the framework

@asottile asottile closed this as completed Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants