views:

129

answers:

4

I'm looking for a Ruby or Python implementation of the Git client that can be used to update and commit changes in a local repository.

I prefer if the library does not use shell commands at all but keeps everything in "pure code".

Are there any?

Thank you in advance.

+3  A: 

Grit gives you object oriented read/write access to Git repositories via Ruby.

require 'grit'
include Grit
repo = Repo.new("/Users/tom/dev/grit")

repo.commits
# => [#<Grit::Commit "e80bbd2ce67651aa18e57fb0b43618ad4baf7750">,
      #<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">,
      #<Grit::Commit "038af8c329ef7c1bae4568b98bd5c58510465493">,
      #<Grit::Commit "40d3057d09a7a4d61059bca9dca5ae698de58cbe">,
      #<Grit::Commit "4ea50f4754937bf19461af58ce3b3d24c77311d9">]

...
The MYYN
+1  A: 

You can check out ruby-git gem.

Eimantas
+2  A: 

There's also Dulwich, a Python implementation of the Git file formats and protocols.

RyanWilcox
+3  A: 

For Python, there is the Dulwich library which @RyanWilcox already mentioned.

For Ruby, there unfortunately is no Git library. There is Grit, which implements a subset of Git in Ruby and wraps the command line tools for some additional features, but only supports the subset of Git that GitHub needs. And you could use either JGit or Git# via JRuby or IronRuby.

Jörg W Mittag