Re: Using git from Python
- From
David Aguilar <davvid@gmail.com>
- Date
- May 8, 2008, 04:23 UTC
- Message-ID
- <402731c90805072123g764a3d56ia30035381c0950dd@mail.gmail.com>
- In-Reply-To
- <87lk2l4fj5.fsf@offby1.atm01.sea.blarg.net>
On Wed, May 7, 2008 at 8:54 PM, Eric Hanchrow <offby1@blarg.net> wrote:
Show 13 quoted lines
> Asheesh> That's fine ... but since I figured others may have done > Asheesh> this also > > As far as I can tell, there is exactly no downside to simply forking a > subprocess. Why are you trying to avoid that? > > Asheesh> raises Exceptions when the git commands fail for some > Asheesh> reason. > > If Popen doesn't already raise an exception when the child process > fails, then it's surely a simple matter to check the exit code, and > raise the exception yourself. >
There have been many questions about this lately. For the impatient, grab git.py from the python-git directory of the ugit project:
http://repo.or.cz/w/ugit.git?a=tree;f=python-git;h=1ef75cef116ce750b5bdf5dd38a4cf1ab2c1ce79;hb=b393c428cf156a7c5c75b18379676dbb534a76d8
http://repo.or.cz/w/ugit.git
I will work on making git.py a separate python-git project, upload it to pypi, and create a separate repo for it very soon.
The interface is blazingly simple. It is a 1:1 correspondance to the git command line interface. e.g. git.commit(F='/some/path.txt', s=True)
There are many examples in the t/ directory and within the ugit project itself. Let me know offline if you have any questions. The documentation could probably use some work.
-- David