Skip to content

Commit

Permalink
Change tfdoc pre-commit hook script to use while read instead of xarg…
Browse files Browse the repository at this point in the history
…s. While (#2717)

probably a bit slower, this works reliably on Linux and OS X. (BSD and GNU
xargs are unfortunately with different arguments) Also added option to set
Python binary (eg. export PYTHON=python3).
  • Loading branch information
rosmo authored Nov 19, 2024
1 parent 44246b4 commit ebc1950
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/pre-commit-tfdoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ set -e
SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$0")")
TFDOC_CMD="${SCRIPT_DIR}/tfdoc.py"
CHECKDOC_CMD="${SCRIPT_DIR}/check_documentation.py"
if [ -z "$PYTHON" ]; then
PYTHON=python
fi

for file in "$@"; do
if [ -d "${file}" ]; then
Expand All @@ -30,4 +33,4 @@ for file in "$@"; do
echo "${dir}"
fi

done | sort | uniq | xargs -I {} /bin/sh -c "echo python \"${TFDOC_CMD}\" {} ; python \"${TFDOC_CMD}\" {} ; echo python \"${CHECKDOC_CMD}\" {} ; python \"${CHECKDOC_CMD}\" {}"
done | sort | uniq | while read -r line; do /bin/sh -c "echo ${PYTHON} \"${TFDOC_CMD}\" \"$line\" ; ${PYTHON} \"${TFDOC_CMD}\" \"$line\" ; echo ${PYTHON} \"${CHECKDOC_CMD}\" \"$line\" ; ${PYTHON} \"${CHECKDOC_CMD}\" \"$line\""; done

0 comments on commit ebc1950

Please sign in to comment.