Is there a way to get more information about the error that occurred? Seeing (pre-receive hook declined) does not really convey the heart of the problem, which is that the file is too big.
Is there a way to get more information about the error that occurred? Seeing (pre-receive hook declined) does not really convey the heart of the problem, which is that the file is too big.
The push method lets us provide our own progress handler. We can make one that will print out the raw output of the git command. You can have it do whatever, log it, collect it, but for this example, let's just print it.
To make one, we can create our own class based on the RemoteProgress class and override the new_message_handler method. This has a function inside it called handler(line) and it seems that this is where all the raw output lines pass through. We can make a small one-line addition to their original code to print out the lines as they get handled.
If we then pass an instance of our new class into a push method's "progress" parameter, we should see the output of the git command print out as it runs.
from git import Repo, RemoteProgress
class MyProgressPrinter(RemoteProgress):
def new_message_handler(self):
"""
:return:
a progress handler suitable for handle_process_output(), passing lines on to this Progress
handler in a suitable format"""
def handler(line):
print(line.rstrip()) # THIS IS THE LINE I ADDED TO THE ORIGINAL METHOD
return self._parse_progress_line(line.rstrip())
# end
return handler
# Now that we've defined it, let's use it...
with Repo('path/to/my/repo/folder') as repo:
origin = repo.remote()
# And then pass in an instance of the new class when you perform your operation:
result = origin.push(progress=MyProgressPrinter())
You can find the original RemoteProgress class and new_message_handler method in this file:
https://github.com/gitpython-developers/GitPython/blob/master/git/util.py