Python Force Git Hook Server Side Output On Same Line In Realtime
git hooks server side output only transmits on a newline. I want to configure a custom task and print real-time output on the same line. How can I achieve that? I tried sys.stdout.
Solution 1:
The problem comes down to the fact that Git itself does not print accumulated remote:
text until the remote sends either a newline or carriage return.
Hence, if we change your inner loop to read:
for i in range(1, 15):
sys.stdout.write('.' * i + '\r')
sys.stdout.flush()
time.sleep(0.5)
you will see the effect you desire.
Note that the \r
moves the print position back to just after the word remote:
, so we must repeat what we have printed so far (hence the need to print first one .
, then two .
s, then three, and so on).
Post a Comment for "Python Force Git Hook Server Side Output On Same Line In Realtime"