Git pre-push: connection closed by the remote host during test execution

I have a pre-push script in my git repository that runs tests. If the tests pass, then the press continues. If the tests fail, it aborts the click.

The script worked fine until the tests began to exceed 3 minutes. stdout shows "Connecting to a bitpacket closed by the remote host" in the middle of the test output. Then all the tests pass, and the click actually fails.

Here's a pre-push script

#!/bin/sh DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) # This script runs tests before any push to the MASTER branch and fails current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') echo "Current branch: "$current_branch if [ $current_branch = "master" ] then echo "Pushing to MASTER branch requires tests to pass..." ./run.sh test if [ $? = 0 ] then exit 0 else echo "***ERROR> Failed to pass tests! Get tests to pass and then try again..." exit 1 fi else echo "Skipping tests since we're not pushing to MASTER..." fi 
+7
source share
3 answers

I ended up git push --no-verify inside a success case. Thus, he effectively pushes twice.

 #!/bin/sh DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) # This script runs tests before any push to the MASTER branch and fails current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') echo "Current branch: "$current_branch if [ $current_branch = "master" ] then echo "Pushing to MASTER branch requires tests to pass..." ./run.sh test if [ $? = 0 ] then # workaround to guarantee my push goes through even if the first attempt times out git push --no-verify exit 0 else echo "***ERROR> Failed to pass tests! Get tests to pass and then try again..." exit 1 fi else echo "Skipping tests since we're not pushing to MASTER..." fi 
+1
source

The answer should explain why git is trying to access Gitlab, Bitbucket or anything else (in my case it is Gitlab), even if the pre-push script is not completed

The pre-push hook was introduced in the commit ec55559, January 2013, Git v1.8.2-rc0

It was part of the as/pre-push-hook patch:

See Commit 87c86dd , commit ec55559 , commit 5a7da2d (January 13, 2013) by Aaron aschrab ( aschrab ) .
(Combined by Junio ​​C Hamano - gitster - in commit bb9a696 , January 24, 2013)

The only other change to it was made by Clemens drizzd ( drizzd ), which obliged af65f68 (November 16, 2015) to ignore SIGPIPE , i.e. to ignore its standard input stream. (Combined by Jeff King - peff - in commit 40fdcc5 , December 01, 2015)

The documentation includes :

Information about what to push is provided on the standard input of the trap in the form of lines:

 <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF 

For example, if the + git push origin master:foreign + command was run, the trap would get a line similar to the following:

 refs/heads/master 67890 refs/heads/foreign 12345 

although full 40-character SHA1s will be provided.

  • If the external ref does not exist yet, <remote SHA1> will be 40 0 .
  • If the link should be removed, <local ref> will be provided as (delete) and <local SHA1> will be 40 0 .

To determine the correct value for the remote SHA1, the transport.c file must communicate with the remote repository (in your case GitLab)

+1
source

Have you checked bitbucket.properties ? Perhaps you will click a few timeouts, for example: process.timeout.execution or plugin.bitbucket-scm-git.backend.timeout.idle . Probably a quick check is to see if there are timeouts set to 180 seconds. Here you can find more information about the available properties.

0
source

Source: https://habr.com/ru/post/1233650/


All Articles