ANSWER POSTED BELOW
I am currently in the process of setting up a local git/development server and have ran into a snag with the gitolite post-hook.
To give an overview of what I am currently doing.
I have setup a local server which contains a 4TB RAID10 being used as a git repository, the machine is also to be used as the local development machine and to streamline the maintenance I am attempting to automate the process of creating Apache Virtualhosts when a new repository is created via gitolite "git-post-init".
I am hoping to accomplish this by cloning the software branch of a repository ( See code below ), adding in the apache vhost config and then symbolically linking it to an apache scanned directory.
The process almost seems to be correct, as I am able to clone the repository add some initial files and create the configuration file but when I attempt to do any git related commands in the repository I am presented with the following error
fatal: Not a git repository: '.'
If I go into the freshly cloned repository after the hook runs I can pull the status of the repository.
Which works ... it just seems that when attempting to do any of this within the hook doesn't.
Below is the code which is being used for the hook with the extra configuration removed to shorten it.
#!/bin/sh # This will create an apache virtualhost file and store it in the # repositories conf/reponame.conf directory and then symlink it to # /home/git/apache/reponame.conf # # A new entry will then be created in the hosts file. echo "Creating a new X Studios project" echo "Git Project config v0.1 author Nickolas Whiting: Oct 20, 2011" REPO=$HOME/repos REPO_PATH=$HOME/repos/$GL_REPO cd $REPO echo "Cloning repo into $REPO_PATH" git clone $GL_REPO_BASE_ABS/$GL_REPO cd $REPO/$GL_REPO echo "Working in $PWD" echo "Adding .gitignore file" touch .gitignore echo "removed for space" >> .gitignore git add -u echo "Commiting changes to repository" git commit -m "Adding ignore file" git push echo "Adding branches" git branch --track management origin/management git branch --track design origin/design git branch --track software origin/software echo "Commiting new branches" git add . git commit -m "Inital Project Setup. Make sure you use the correct branch for what you are doing!" git push echo "Checking out the software branch" git checkout software echo "Creating Apache Virtualhost configuration" echo "Removed for space" >> $REPO_PATH/conf/$GL_REPO.conf echo "Creating symbolic link" ln -s $REPO_PATH/$GL_REPO.conf $HOME/apache/$GL_REPO.conf echo "Commiting changes to the repository" echo "DONE"
I am new to writing bash scripts so if anything is wrong or could be done better please let me know,
Thanks for the help!
If anyone else ever has this problem
Apparently when running inside a gl hook the
GIT_DIR variable is set to '.' ( which is apparent ) setting this to the repository .git directory solves the problem
Hope this saves someone the hours I wasted on this!