GitShelve makes it possible to store arbitrary data in a separate branch of a git repository (not maintained anymore)
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
LICENSE
README.textile
git_shelve.gemspec

README.textile

GitShelve

GitShelve makes it possible to store arbitrary data in a separate branch
of a git repository
This class was inspired and is loosely based upon John Wiegley’s
git_shelve.py and git-issues python scripts (http://github.com/jwiegley/git-issues/tree/master)

Installation

You can either download the archive via github
or install the git_shelve gem:

  sudo gem install gem install siebertm-git_shelve --source=http://gems.github.com

Basic Usage


  shelve = GitShelve::Shelve.new("mybranch", "/path/to/repository.git")
  sha1 = shelve.put("some data")

  shelve.get(sha1)
  #-> "some data"

  sha1 = shelve.put do |f|
    # f is an IO object streaming directly into git!
    f.write("i can ")
    f.write("stream my data ")
    f.write("in chunks!")
  end

  shelve.get(sha1)
  #-> "i can stream my data in chunks!"

  shelve.get(sha1) do |f|
    # this works the same with get!
    data = f.read
  end

  data
  #-> "i can stream my data in chunks!"

Replication

GitShelve now supports replication, which is based on git’s
distribution mechanisms (see git-fetch-pack and git-send-pack
manpages). Pulling and fentching from remote repositories is being
implemented by the GitShelve::ReplicatedShelve class, so you could
use the basic Shelve class if you don’t need that stuff.

Since I decided to use just the plumbing, replication is not based on
git remotes, so you’ll have to provide ReplicatedShelve with the remotes
“by hand”.

Another thing that could cause errors is that you really should use the
same branch on all remotes. I did not test it with different branches.


  shelve = GitShelve::ReplicatedShelve.new("mybranch", "/path/to/repository")
  shelve.add_remote("git@example.com:remote_repo")
  
  # get automatically fetches from remotes if it can't find an object,
  # so this will pull from the remote repository
  data = shelve.get("37295dbe4bb6d980d2d8ce2dc16bfc29ab56526e")
  
  # you could also use this
  shelve.fetch
  data = shelve.get("37295dbe4bb6d980d2d8ce2dc16bfc29ab56526e")
  
  # now lets create some data and push it to the server
  shelve.put("some data")
  shelve.push

Author

Michael Siebert <siebertm85@googlemail.com>

This piece of software wouldn’t be possible without Git. Thanks
go out to the people who invented git!