-
I'm trying to write a pre-receive hook. When using the repl, I get the following results:
Here is the relevant content of my pre-receive hook file:
However, when I trigger this with a push, this is the result:
I don't get it... How could it work in the REPL but not in code? Could there be some sort of difference in the shell environment that GitPython uses? But if so, what? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Further digging has revealed that the problem indeed lies in the fact that, when the hook runs the code, cmd.stdout.readline() just returns a blank... |
Beta Was this translation helpful? Give feedback.
-
To me it looks like My expectation would be that the above works though. |
Beta Was this translation helpful? Give feedback.
-
OK, so I put the same code into a pre-commit hook and that did not fail. So that makes it pretty obvious to me that it is not the shell environment, but rather the state of the repository during the pre-receive hook that is at fault. I have tried the debugging settings, but unfortunately, it seems this particular command does not get debugged properly:
As you can see, some early git commands do get logged but not the one that gives no output... Something else I tried was putting the repo into the pre-receive state by making a pre-receive hook that just looped infintely ( |
Beta Was this translation helpful? Give feedback.
-
Thanks for the heads-up. Since it's something with the way GitPython obtains object information, you could try to instantiate the repository with a different object database implementation. The one implemented in pure python would certainly provide better error messages, maybe it works even. Something I can imagine to be the reason for this issue in the first place is a different run environment, as the |
Beta Was this translation helpful? Give feedback.
-
Well now, using the As for the environment, I did dump |
Beta Was this translation helpful? Give feedback.
-
Thanks again! Please allow me nonetheless to close this issue as answered question due to the discovery of a workaround. Hopefully people will be able to find it when encountering similar issues. In order to reopen, there should be script(s) to make this issue reproducible. |
Beta Was this translation helpful? Give feedback.
Thanks for the heads-up. Since it's something with the way GitPython obtains object information, you could try to instantiate the repository with a different object database implementation.
The one implemented in pure python would certainly provide better error messages, maybe it works even.
Something I can imagine to be the reason for this issue in the first place is a different run environment, as the
git
command is influenced by plenty of environment variables which are set in hooks only.