mirror of
https://github.com/AdaCore/git-hooks.git
synced 2026-02-12 12:43:11 -08:00
While testing the behavior of the git-hooks under Python 3.x, I noticed that the order of some output was not the same as when running it with Python 2.x. When investigating further, I found that the order with Python 2.x made better sense, and that the different order was caused by stdout/stderr buffering. This commit turns buffering off entirely in an effort to make sure that output sent to stdout & stderr gets seen in the order that it was sent. As it happens, while this commit was aimed at Python 3.x, running the testsuite showed that we had one testcase where the order when using Python 2.x was also incorrect, and therefore misleading, for a couple of tests. The tests' expected output was double-checked, and adjusted accordingly, with additional comments explaining what each part was about. TN: U530-006 Change-Id: Iaf2c5266e13a645dab006e1f7f4cb553cbd5704f
54 lines
1.9 KiB
Bash
Executable File
54 lines
1.9 KiB
Bash
Executable File
#! /usr/bin/env bash
|
|
|
|
# This script is expected to be called with the following arguments:
|
|
# (1) refname: The name of the reference being updated
|
|
# (refs/heads/master, for instance).
|
|
# (2) oldrev: This is the commit that the reference was pointing to
|
|
# before the update.
|
|
# (3) newrev: This is the commit that the ref should point to, if
|
|
# the update is accepted.
|
|
#
|
|
# This script should return 0 if the update should be allowed,
|
|
# and nonzero otherwise.
|
|
|
|
# The following safety checks verify that the script is being
|
|
# called correctly. They have been copied directly from the
|
|
# sample "update" script provided by git.
|
|
|
|
if [ -z "$GIT_DIR" ]; then
|
|
echo "Don't run this script from the command line." >&2
|
|
echo " (if you want, you could supply GIT_DIR then run" >&2
|
|
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# The following is sourceware-specific. Some of the tools installed
|
|
# on that machine are too old, causing some really interesting features
|
|
# to be missing (Eg: python's OrderedDict, for instance, or git's %B
|
|
# format placeholder). So, local installs of more recent versions have
|
|
# been placed in /opt/rh/[...].
|
|
for tool in git19 python27
|
|
do
|
|
if [ -f /opt/rh/$tool/enable ]; then
|
|
. /opt/rh/$tool/enable
|
|
fi
|
|
done
|
|
|
|
# The following is AdaCore-specific: It allows us to make sure that
|
|
# we are not running a random version of Python, but rather the
|
|
# baseline version installed in /gnatmail.
|
|
export PATH=/gnatmail/local/gnatpython/bin:$PATH
|
|
|
|
# Similarly, update the PATH and LD_LIBRARY_PATH to include the location
|
|
# where cvs_check is installed.
|
|
for cvs_check_dir in /svn/Dev/hooks /usr/local/svn-hooks \
|
|
/jouy.a/web/services/gnos/bin; do
|
|
if [ -d $cvs_check_dir ]; then
|
|
export PATH=$cvs_check_dir:$PATH
|
|
export LD_LIBRARY_PATH=$cvs_check_dir/cvs_check.libs:$LD_LIBRARY_PATH
|
|
fi
|
|
done
|
|
|
|
python -u `dirname $0`/update.py "$@"
|
|
|