Skip to content

Commit

Permalink
Release 0.2.3 - Severe bug fixed. Reading of tree entries was broken.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgi committed Mar 20, 2009
1 parent 2eb201e commit 67eecda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions git_store.gemspec
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'git_store'
s.version = '0.2.2'
s.date = '2009-1-1'
s.version = '0.2.3'
s.date = '2009-3-20'
s.summary = 'a simple data store based on git'
s.author = 'Matthias Georgi'
s.email = 'matti.georgi@gmail.com'
Expand Down
13 changes: 7 additions & 6 deletions lib/git_store/tree.rb
@@ -1,5 +1,3 @@
require 'strscan'

class GitStore

class Tree
Expand Down Expand Up @@ -50,6 +48,7 @@ def tree(name)
def load_from_disk
dir = File.join(store.path, self.path)
entries = Dir.entries(dir) - ['.', '..']

@table = entries.inject({}) do |hash, name|
if name[-1, 1] != '~' && name[0, 1] != '.'
path = "#{dir}/#{name}"
Expand All @@ -71,11 +70,13 @@ def load_from_disk
#
# Return an array of [mode, name, id] entries.
def read_contents(data)
scanner = StringScanner.new(data)
contents = []

while scanner.scan(/(.*?) (.*?)\0(.{20})/m)
contents << [scanner[1], scanner[2], scanner[3].unpack("H*").first]

while data.size > 0
mode, data = data.split(" ", 2)
name, data = data.split("\0", 2)
id = data.slice!(0, 20).unpack("H*").first
contents << [ mode, name, id ]
end

contents
Expand Down
4 changes: 1 addition & 3 deletions test/git_store_spec.rb
@@ -1,6 +1,4 @@
require 'git_store'
require 'yaml'
require 'pp'

describe GitStore do

Expand Down Expand Up @@ -74,7 +72,7 @@ def self.it(text, &block)
it 'should load a repo' do
file 'a', 'Hello'
file 'b', 'World'

store.load

store['a'].should == 'Hello'
Expand Down

0 comments on commit 67eecda

Please sign in to comment.