I am trying to build a git hook in this case post-receive however it only works when called directly from shell.
A minimal example script:
#! /bin/env python3
import git
rep = git.Repo("/var/www/cgi-bin/deployed.everland")
print(rep.git.status())
results in the following error when called by git:
$ git push --tags
Total 0 (delta 0), reused 0 (delta 0)
remote: Traceback (most recent call last):
remote: File "hooks/post-receive", line 6, in <module>
remote: print(rep.git.status())
remote: File "/usr/lib/python3.5/site-packages/git/cmd.py", line 424, in <lambda>
remote: return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
remote: File "/usr/lib/python3.5/site-packages/git/cmd.py", line 873, in _call_process
remote: return self.execute(call, **_kwargs)
remote: File "/usr/lib/python3.5/site-packages/git/cmd.py", line 687, in execute
remote: raise GitCommandError(command, status, stderr_value, stdout_value)
remote: git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
remote: cmdline: git status
remote: stderr: 'fatal: Not a git repository: '.''
To host:testrepos
* [new tag] newtag -> newtag
I don't understand why it is opening the git repository at '.' as I clearly stated otherwise.