Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork940
Make GitPython IndexFile.commit() work from a cron job#52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…duid() instead of os.getlogin(). Ref:https://groups.google.com/forum/#\!msg/git-python/NU7APS5i5Xw/uziOFlneZ8gJ
Just for completeness, I post Alex's detailed email here:Hi all, We are having a new issue with GitPython, version 0.3.2.RC1. Still doing continuous deployment from a cool script, hopefully in a cron job. When doing a commit from an index in the cron job we were getting a silent error. However running the script manually was fine. My colleague tracked it to an error in os.getlogin() when run from cron. This StackOverflow post explains it very well. The official docs say:
We have tried that, and it works, but we don't want to patch the sources locally; it would be great if you could apply the patch on the GitPython source. The fix is quite simple: in util.py line 120, replace:
with
Of course the line above also references os.getlogin() indirectly:
So you might want to change that too. The complete patch is attached. For reference, there are a couple of workarounds. One is setting the $USER or $USERNAME environment variables (not tested). Another (and the one we have settled for) is doing the commits using
which works just fine. Thanks in advance, Alex. |
Why not simply replace this with getpass.getuser()1 ? |
I totally agree, thecurrent implementation is bloated and does in fact already include the behaviour of this pull request. |
Make GitPython IndexFile.commit() work from a cron job: use pwd.getpwduid() instead of os.getlogin(). Ref:https://groups.google.com/forum/#!msg/git-python/NU7APS5i5Xw/uziOFlneZ8gJ