{"id":31526971,"url":"https://github.com/repotag/rjgit","last_synced_at":"2025-10-03T21:16:49.703Z","repository":{"id":7736887,"uuid":"9103531","full_name":"repotag/rjgit","owner":"repotag","description":"A JRuby wrapper around the JGit library for manipulating Git repositories, the Ruby way.","archived":false,"fork":false,"pushed_at":"2025-08-23T13:15:43.000Z","size":131504,"stargazers_count":40,"open_issues_count":7,"forks_count":16,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-25T11:57:54.743Z","etag":null,"topics":["git","jgit","jgit-library","jruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/repotag.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-03-29T17:51:29.000Z","updated_at":"2025-01-13T13:40:56.000Z","dependencies_parsed_at":"2024-06-19T05:17:33.005Z","dependency_job_id":"c3199e63-d956-4f52-82d8-d36c1500ecfb","html_url":"https://github.com/repotag/rjgit","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/repotag/rjgit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repotag%2Frjgit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repotag%2Frjgit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repotag%2Frjgit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repotag%2Frjgit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/repotag","download_url":"https://codeload.github.com/repotag/rjgit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repotag%2Frjgit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278228305,"owners_count":25952078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","jgit","jgit-library","jruby"],"created_at":"2025-10-03T21:16:44.788Z","updated_at":"2025-10-03T21:16:49.696Z","avatar_url":"https://github.com/repotag.png","language":"Ruby","readme":"RJGit\n=====\n\n### A JRuby wrapper around the [JGit library](https://eclipse.dev/jgit/) for manipulating Git repositories, the Ruby way.\n\n[![Ruby Build](https://github.com/repotag/rjgit/actions/workflows/test.yaml/badge.svg)](https://github.com/repotag/rjgit/actions/workflows/test.yaml)\n[![Coverage Status](https://coveralls.io/repos/repotag/rjgit/badge.png?branch=master)](https://coveralls.io/r/repotag/rjgit)\n[![Gem Version](https://badge.fury.io/rb/rjgit.png)](http://badge.fury.io/rb/rjgit)\n[![Cutting Edge Dependency Status](https://cuttingedge.onrender.com/github/repotag/rjgit/svg 'Cutting Edge Dependency Status')](https://cuttingedge.onrender.com/github/repotag/rjgit/info)\n\nSummary\n-------\n\nRJGit provides a fully featured library for accessing and manipulating git repositories by wrapping the Java [JGit library](https://github.com/eclipse/jgit). It thus provides similiar functionality as e.g. [rugged](https://github.com/libgit2/rugged) on JRuby.\n\nInstallation\n------------\n\nInstall the rjgit gem with:\n\n```sh\n$ gem install rjgit\n```\n\n#### Version scheme\n\nRJGit's version number is the version of jgit used, plus our own patch level counter. For instance, RJGit 4.0.1.0 uses jgit 4.0.1, patch level 0.\n\nUsage\n-----\nRJGit wraps most (if not all) of JGit's core functionality; it has classes for all important Git objects, i.e., Repo, Blob, Tree, Commit, and Tag. It allows parsing and manipulation of these objects in an intuitive manner, either simulating ordinary git usage (with a working directory on disk) or on a lower level, through creating new git objects manually (also works with 'bare' repositories, without a working directory).\n\nSee below for some examples of what you can do with RJGit. Make sure you have [JRuby](http://jruby.org/) installed.\n\n### Require the gem and include the RJGit module\n\n```ruby\nrequire \"rjgit\"\ninclude RJGit\n```\n\n### Initializing an existing repository on the filesystem\n\n```ruby\nrepo = Repo.new(\"repo.git\")\n```\n\n### Creating a new repository\n\n```ruby\nrepo = Repo.new(\"repo.git\", :create =\u003e true)\nrepo = Repo.new(\"repo.git\", :create =\u003e true, :is_bare =\u003e true) # Create a 'bare' git repo.\nrepo.bare? # Is this a bare repository?\n```\n\n### Getting commits\n```ruby\nrepo.commits('master')\nrepo.commits('959329025f67539fb82e76b02782322fad032821')\nrepo.head\ncommit = repo.commits('master').first # a Commit object; try commit.actor, commit.id, etc.\n```\n\n### Getting branches\n\n```ruby\nrepo.branches\n```\n\n### Finding a single object by SHA\n```ruby\nrepo.find('959329025f67539fb82e76b02782322fad032821')\nrepo.find('959329025f67539fb82e76b02782322fad032821', :commit) # Find a specific :commit, :blob, :tree, or :tag\n```\n\n### Blobs and Trees\n\n```ruby\nblob = repo.blob(\"example/file.txt\") # Retrieve a file by filepath, from the HEAD commit...\nblob = repo.blob(\"example/file.txt\", \"refs/heads/mybranch') # Retrieve the same file from a different branch\nblob = repo.find(\"959329025f67539fb82e76b02782322fad032822\", :blob) # ...or by SHA\nblob.data # Cat the file; also blob.id, blob.mode, etc.\ntree = repo.tree(\"example\") # Retrieve a tree by filepath...\ntree = repo.find(\"959329025f67539fb82e76b02782322fad032000\", :tree) #...or by SHA\ntree.data # List the tree's contents (blobs and trees). Also tree.id, tree.mode, etc.\ntree.each {|entry| puts entry.inspect} # Loop over the Tree's children (Blobs and Trees)\ntree.find_blob {|entry| entry[:name] == 'foo.txt'} # Find a single blob that matches the block\ntree.find_tree {|entry| entry[:name] == 'mytree' } # Find a single tree that matches the block\ntree.find {|entry| ...} # Find a single entry that matches the block\ntree.find_all {|entry entry[:name].include?('.') } # Find all entries matching the block\ntree.trees # An array of the Tree's child Trees\ntree.blobs # An array of the Tree's child Blobs\nPorcelain::ls_tree(repo, repo.tree(\"example\"), :print =\u003e true, :recursive =\u003e true, :ref =\u003e 'mybranch') # Outputs the Tree's contents to $stdout. Faster for recursive listing than Tree#each. Passing nil as the second argument lists the entire repository. ref defaults to HEAD.\n```\n\n### Getting tags\n```ruby\ntag = repo.tags['example_tag']\ntag.id # tag's object id\ntag.author.name # Etcetera\nsome_object = Porcelain.object_for_tag(repo, tag) # Returns the tagged object; e.g. a Commit\n```\n\n### Getting notes\n\n```ruby\nrepo.notes\nnote = repo.head.note\nnote.message # the String message of the note\nnote.annotates # the SHA ID of the object this note is attached to\nrepo.head.note = \"Happy note writing\"\nrepo.head.note_remove\n```\n\n### Getting diffs\n```ruby\nsha1 = repo.head.id\nsha2 = repo.commits.last.id\noptions = {:old_rev =\u003e sha2, :new_rev =\u003e sha1, :file_path =\u003e \"some/path.txt\", :patch =\u003e true}\nPorcelain.diff(repo, options)\n```\n\n### Logs\n\n```ruby\nrepo.git.log # Returns an Array of Commits constituting the log for the default branch\nrepo.git.log(\"follow-rename.txt\", \"HEAD\", follow: true, list_renames: true) # Log for a specific path, tracking the pathname over renames. Returns an Array of TrackingCommits, which store the tracked filename: [#\u003cRJGit::TrackingCommit:0x773014d3 @tracked_pathname=\"follow-rename.txt\" ...\u003e]\n```\n\n### Creating blobs and trees from scratch\n```ruby\nblob = Blob.new_from_string(repo, \"Contents of the new blob.\") # Inserts the blob into the repository, returns an RJGit::Blob\ntree = Tree.new_from_hashmap(repo, {\"newblob\" =\u003e \"contents\", \"newtree\" =\u003e { \"otherblob\" =\u003e \"this blob is contained in the tree 'newtree'\" } } ) # Constructs the tree and its children based on the hashmap and inserts it into the repository, returning an RJGit::Tree. Tree.new_from_hashmap takes an RJGit::Tree as an optional third argument, in which case the new tree will consist of the children of that Tree *plus* the contents of the hashmap.\n```\n\n### Committing and adding branches to repositories, 'porcelain' style (only works with non-bare repos)\n```ruby\nrepo.create_branch('new_branch') # Similarly for deleting, renaming\nrepo.checkout('new_branch')\nrepo.add('new_file.txt') # Similarly for removing\nrepo.commit('My message')\nrepo.update_ref(commit) # Fast forward HEAD (or another ref) to the commit just created\n```\n\n### Committing and adding branches to repositories, 'plumbing' style (also works with bare repos)\n```ruby\nrepo = repo.new(\"repo.git\")\ntree = Tree.new_from_hashmap(repo, {\"newblob\" =\u003e \"contents\"}, repo.head.tree ) # As above, use the current head commit's tree as a starting point and add \"newblob\"\nactor = RJGit::Actor.new(\"test\", \"test@repotag.org\")\ncommit = Commit.new_with_tree(repo, tree, \"My commit message\", actor) # Create a new commit with tree as base tree\n```\n\n### And more...\n```ruby\npack = RJGitReceivePack.new(repo) # Implement the smart-http protocol with RJGitReceivePack and RJGitUploadPack\npack.receive(client_msg) # Respond to a client's GET request\nrepo.config['remote origin']['url'] # Retrieve config values\nPorcelain::diff(repo, options)\nPorcelain::blame(repo, options)\n```\n\nIssues\n---------------\nPlease let us know by creating a [github issue](https://github.com/repotag/rjgit/issues).\n\nContributing\n---------------\n\n\n1. Fork the project\n1. Create a new branch\n1. Modify the sources\n1. Add specs with full coverage for your new code\n1. Make sure the whole test suite passes by running `bundle exec rake`\n1. Push the branch up to GitHub\n1. Send us a pull request\n\nAuthors\n-------\n\nRJGit is being developed by:\n\n- [Bart Kamphorst](https://github.com/bartkamphorst)\n- [Dawa Ometto](https://github.com/dometto)\n\n\n\n\nLicense\n-------\nCopyright (c) 2011 - 2023, Team Repotag\n\n(Modified BSD License)\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright\n  notice, this list of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above copyright\n  notice, this list of conditions and the following disclaimer in the\n  documentation and/or other materials provided with the distribution.\n* Neither the name of the organization nor the\n  names of its contributors may be used to endorse or promote products\n  derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL \u003cCOPYRIGHT HOLDER\u003e BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frepotag%2Frjgit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frepotag%2Frjgit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frepotag%2Frjgit/lists"}