On my gitolite I want to automatically generate documentation when a repository is updated. For that I generated a repo-specific hook that calls a bash script which either clones the repository and generates a documentation in it or if the directory already exists it pulls the updates and then generates documentation.
The remote hook gets called however git does not recognize the directory. It for some reason works in '.' and doesn't find a .git directory there (but it is there, because it cloned it in a script run before).
remote: + /home/git/check_jsdoc.sh kbc
remote: + reponame=kbc
remote: + echo 'Generating documentation for:' kbc
remote: Generating documentation for: kbc
remote: + jsdocdir=/home/git/jsdoc/
remote: + repodir=/home/git/jsdoc/kbc
remote: + test -d /home/git/jsdoc/kbc
remote: + echo '/home/git/jsdoc/kbc exists.'
remote: /home/git/jsdoc/kbc exists.
remote: + test -d /home/git/jsdoc/kbc/.git
remote: + git -C /home/git/jsdoc/kbc pull
remote: fatal: not a git repository: '.'
remote: + documentation build /home/git/jsdoc/kbc/src/App.js -f html -o /var/www/jsdoc/kbc
remote: + exit
Here is the script:
#!/bin/bash
set -x
reponame=$1
echo "Generating documentation for: ${reponame}"
jsdocdir="/home/git/jsdoc/"
repodir="${jsdocdir}${reponame}"
if test -d "$repodir"; then
echo "${repodir} exists."
if test -d "${repodir}/.git"; then
git -C "$repodir" pull
else
echo "no .git in ${repodir}?"
fi
else
cd "$jsdocdir" || exit 1
git clone gitolite:"$reponame"
cd "$jsdocdir" || exit 1
fi
documentation build "${repodir}/src/App.js" -f html -o "/var/www/jsdoc/${reponame}"
when I run check_jsdoc.sh kbc locally, it works
git@gitserver:~$ ./check_jsdoc.sh kbc
+ reponame=kbc
+ echo 'Generating documentation for:' kbc
Generating documentation for: kbc
+ jsdocdir=/home/git/jsdoc/
+ repodir=/home/git/jsdoc/kbc
+ test -d /home/git/jsdoc/kbc
+ echo '/home/git/jsdoc/kbc exists.'
/home/git/jsdoc/kbc exists.
+ test -d /home/git/jsdoc/kbc/.git
+ git -C /home/git/jsdoc/kbc pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 1), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), 394 bytes | 394.00 KiB/s, done.
From gitolite:kbc
b708b925..aa11c17d master -> origin/master
Updating b708b925..aa11c17d
Fast-forward
+ documentation build /home/git/jsdoc/kbc/src/App.js -f html -o /var/www/jsdoc/kbc