0
我想在這種情況下構建一個git鉤子post-receive,但它只在直接從shell調用時才起作用。gitPython不能從git鉤子工作
小例子腳本:
#! /bin/env python3
import git
rep = git.Repo("/var/www/cgi-bin/deployed.everland")
print(rep.git.status())
導致以下錯誤時混帳叫:
$ 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
我不明白爲什麼它在'.'
,因爲我清楚地打開Git倉庫另有說明。