Githook problem
Posted: Tue Jan 07, 2020 11:42 pm
Has anyone worked with githooks as part of their commit to a github repo?
The following script works when I run it from Git BASH or a command window, but seems to be ignored when I commit from inside oXygen.
The following script works when I run it from Git BASH or a command window, but seems to be ignored when I commit from inside oXygen.
Code: Select all
#!/bin/sh
set -x
# In order to run this pre-commit hook the user will need the following setup
# 1. The DITA-OT command utility needs to be added to the path
# In Windows, typically this path is: "C:\DEV\DITA-OT\dita-ot-3.4\bin"
# 2. Git needs to be installed on your computer. (https://git-scm.com/download/)
# 3. Run 'git config core.hooksPath .githooks' in the repo folder to add the Git symlink.
# There is no confirmation.
# 3. Run 'chmod +x .githooks/pre-commit' in the repo folder to add the Git symlink.
# There is no confirmation.
# Populate all the .DITA* files for this commit
ditafiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.dita*')
# Get the absolute path of the `.git/hooks` directory
export GIT_HOOKS=`cd "\`dirname "\\\`readlink "$0" || echo $0\\\`"\`" && pwd`
# Loop over the files, find their directory, and generate the README within that directory
for arg in $ditafiles; do
BASE_DIRECTORY=$(echo "$arg" | cut -d "/" -f1)
# Set the absolute path of the build directory
export BUILD_FILES="$GIT_HOOKS/../$BASE_DIRECTORY"
# Now that we have the base path to the project we can run the DITA command to generate that specific README
dita --input=$BUILD_FILES/README.ditamap --format=markdown -Dchunk=to-content --output=$BUILD_FILES/docs/
done
# Exit with status of last command
exit 0