###A JRuby wrapper around the JGit library for manipulating Git repositories, the Ruby way.
RJGit is being developed by Team Repotag:
With special thanks to:
Install the rjgit gem with the command:
$ gem install rjgit
- JRuby >= 1.7.0
- mime-types >= 1.15
- rake >= 0.9.2.2
- rspec >= 2.0
- simplecov
RJGit wraps most (if not all) of JGit's core functionality; see below for some examples of what you can do with it. Make sure you have JRuby installed.
require "rjgit"
include RJGit
repo = Repo.new("repo.git")
repo = Repo.new("repo.git", :create => true)
repo = Repo.new("repo.git", :create => true, :is_bare => true) # Create a 'bare' git repo, which stores all git-data under the '.git' directory.
repo.commits('master')
repo.commits('959329025f67539fb82e76b02782322fad032821')
# Similarly for getting tags, branches, trees (directories), and blobs (files).
tag = repo.tags['example_tag']
tag.id # tag's object id
tag.author.name # Etcetera
repo.blob("example/file.txt") # Retrieve a file by filepath
repo.blob("example/file.txt").data # Cat the file
repo.tree("example") # Retrieve a tree by filepath
repo.tree("example").data # List the tree's contents (blobs and trees)
Porcelain::ls_tree(repo, repo.tree("example"), :print => true, :recursive => true, :branch => 'mybranch') # Outputs a file list to $stdout. Passing nil as the second argument lists the entire repository. Branch defaults to HEAD.
repo.create_branch('new_branch') # Similarly for deleting, renaming
repo.checkout('new_branch')
repo.add('new_file.txt') # Similarly for removing
repo.commit('My message')
pack = RJGitReceivePack.new(repo) # Implement the smart-http protocol with RJGitReceivePack and RJGitUploadPack
pack.receive(client_msg) # Respond to a client's GET request
repo.config['remote origin']['url'] # Retrieve config values
Porcelain::diff(repo, options)
Porcelain::blame(repo, options)
Please let us know by creating a github issue.
- Fork the project
- Create a new branch
- Modify the sources
- Add specs with full coverage for your new code
- Make sure the whole test suite passes by running rake
- Push the branch up to GitHub
- Send us a pull request
- Start the nailgun server
jruby --ng-server &
- Run rake against the nailgun instance
jruby --ng -S rake
Copyright (c) 2011 - 2013, Team Repotag
(Modified BSD License)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.