public
Description: GitShelve makes it possible to store arbitrary data in a separate branch of a git repository
Homepage: http://www.siebert-wd.de/projects/git-shelve
Clone URL: git://github.com/siebertm/git-shelve.git
Click here to lend your support to: git-shelve and make a donation at www.pledgie.com !
name age message
file .gitignore Sun May 18 05:54:49 -0700 2008 Update .gitignore [siebertm]
file LICENSE Sun May 18 01:25:11 -0700 2008 Added License (LGPLv3) [siebertm]
file README.textile Sun May 18 06:03:36 -0700 2008 Update Docs: * README now mentions that we're a... [siebertm]
file git_shelve.gemspec Sun May 18 05:55:18 -0700 2008 Add .gemspec file [siebertm]
directory lib/ Sun May 18 06:03:36 -0700 2008 Update Docs: * README now mentions that we're a... [siebertm]
directory spec/ Sun May 18 05:06:39 -0700 2008 A big update: * reorganized directory structure... [siebertm]
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!