Git library for Ruby or Python?

I am looking for a Ruby or Python implementation for a Git client that can be used to update and commit changes to a local repository.

I prefer if the library does not use shell commands at all, but stores everything in "clean code".

Whether there is a?

Thanks in advance.

+7
git python ruby
source share
6 answers

There is also Dulwich , an implementation of the Git formats and protocols in Python.

+9
source share

Grit gives object-oriented read / write access to Git repositories through 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">] ... 
+6
source share

You can check ruby-git gem .

+3
source share

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

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

+3
source share

There is now libgit2 : a C library sponsored by Github with many bindings , including Ruby and Python.

+3
source share

GitPython has an object-oriented API similar to Grit:

 >>> #$ pip install GitPython >>> import git >>> repo = git.Repo('.') >>> repo.git_dir '/home/hobs/src/twip/.git' >>> repo.bare False >>> repo.untracked_files [u'twip/scripts.bak/__init__.py', u'twip/scripts.bak/cat_tweets.py', u'twip/scripts.bak/clean.py', u'twip/scripts.bak/explore.py', u'twip/scripts.bak/generate.py', u'twip/scripts.bak/plot_globe.py', u'twip/scripts.bak/skeleton.py'] >>> repo.head.ref <git.Head "refs/heads/master"> >>> repo.tags [<git.TagReference "refs/tags/0.0.1">, <git.TagReference "refs/tags/0.0.2">, <git.TagReference "refs/tags/0.0.3">] 
0
source share

All Articles