I ahve django project hosted with Apache+mod_wsgi.I am trying to pull update using git command via subprocess, like:
subprocess.check_output(['git', 'pull', 'origin', 'mybranch'])
However, I am getting error like:
Command '['git', 'pull', 'origin', 'mybranch']' returned non-zero exit status 128
This problem appears when I call this function via browser. If I run subprocess.check_output(['git', 'pull', 'origin', 'mybranch'])
from python sell, there will not error. It works perfectly as intended.
I had the same issue twice with git grep.
It came the second time from the fact I forgot to add www-data
to the group which has read rights on the git repository folder.
Also, as git command need to be run from inside a git repo, you may want to try by adding '--git-dir='
and '--work-tree='
in your argument list, just after the git main command :
gd = '--git-dir=' + os.path.join(repo_path, '.git')
wt = '--work-tree=' + repo_path
gg_matches = subprocess.check_output(["git", gd, wt, "grep"] + gg_opt)
It is required if your cwd is different from your repo_path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With