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 !
siebertm (author)
Sun May 18 05:55:18 -0700 2008
commit  403d5191dbf2f1e876f43c8f64d7cd5c69e91214
tree    d8c5bb7b0391f8bf7998253e8bf3972bcaa28467
parent  732c88eaed5426e10dceb468f368411a12a25934
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 Loading commit data...
file git_shelve.gemspec Sun May 18 05:55:18 -0700 2008 Add .gemspec file [siebertm]
directory lib/
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)

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!