relaxo 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/relaxo/changeset.rb +1 -1
- data/lib/relaxo/database.rb +28 -0
- data/lib/relaxo/version.rb +1 -1
- data/spec/relaxo/database_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 801d2413ec4ce9a0befc4ad46726900c09453cb8
|
4
|
+
data.tar.gz: e9b179cd2f9a6da4083848c3197f69b328dc455e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f5c211fdb870371d30dd6555b556771a78a12408004db4bc1be125bcced2daa64bf05c989a8a8045b0456a64cc277d9fc1d132af9f26ed6a76c7ede4c3714af
|
7
|
+
data.tar.gz: 9f6a3c721c120a000666fb192fc2d779ff62a3d0ab714cc24f75284bfa6ca1bfe72cd5e32be469c241af28a43b6a3309f683dda823a76ecd74dd638eba176c68
|
data/README.md
CHANGED
@@ -106,6 +106,17 @@ Reading data is lighting fast as it's loaded directly from disk and cached.
|
|
106
106
|
|
107
107
|
As Relaxo is unapologetically based on git, you can use git directly with a non-bare working directory to add any files you like. You can even point Relaxo at an existing git repository.
|
108
108
|
|
109
|
+
### Durability
|
110
|
+
|
111
|
+
Relaxo is based on `libgit2` and asserts that it is a transactional database. We base this assertion on:
|
112
|
+
|
113
|
+
- All writes into the object store using `libgit2` are atomic and synchronized to disk.
|
114
|
+
- All updates to refs are atomic and synchronized to disk.
|
115
|
+
|
116
|
+
Provided these two invariants are maintained, the operation of Relaxo will be safe, even if there are unexpected interruptions to the program.
|
117
|
+
|
118
|
+
The durability guarantees of Relaxo depend on [`libgit2` calling `fsync`](https://github.com/libgit2/libgit2/pull/4030), and [this being respected by the underlying hardware](http://www.evanjones.ca/intel-ssd-durability.html). Otherwise, durability cannot be guaranteed.
|
119
|
+
|
109
120
|
## Contributing
|
110
121
|
|
111
122
|
1. Fork it
|
data/lib/relaxo/changeset.rb
CHANGED
data/lib/relaxo/database.rb
CHANGED
@@ -75,6 +75,34 @@ module Relaxo
|
|
75
75
|
return dataset
|
76
76
|
end
|
77
77
|
|
78
|
+
# revision history of given object
|
79
|
+
def history(path)
|
80
|
+
head, _ = latest_commit
|
81
|
+
|
82
|
+
walker = Rugged::Walker.new(@repository) # Sounds like 'Walker, Texas Ranger'...
|
83
|
+
walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
|
84
|
+
walker.push(head.oid)
|
85
|
+
|
86
|
+
commits = []
|
87
|
+
|
88
|
+
old_oid = nil
|
89
|
+
|
90
|
+
walker.each do |commit|
|
91
|
+
dataset = Dataset.new(@repository, commit.tree)
|
92
|
+
oid = dataset.read(path).oid
|
93
|
+
|
94
|
+
if oid != old_oid # modified
|
95
|
+
yield commit if block_given?
|
96
|
+
commits << commit
|
97
|
+
old_oid = oid
|
98
|
+
end
|
99
|
+
|
100
|
+
break if oid.nil? && !old_oid.nil? # deleted or moved
|
101
|
+
end
|
102
|
+
|
103
|
+
return commits
|
104
|
+
end
|
105
|
+
|
78
106
|
private
|
79
107
|
|
80
108
|
def track_time(message)
|
data/lib/relaxo/version.rb
CHANGED
@@ -84,4 +84,20 @@ RSpec.describe Relaxo::Database do
|
|
84
84
|
expect(dataset.each('test').count).to be == 10
|
85
85
|
end
|
86
86
|
end
|
87
|
+
|
88
|
+
it "can enumerate commit history of a document" do
|
89
|
+
10.times do |id|
|
90
|
+
database.commit(message: "revising the document #{id}") do |changeset|
|
91
|
+
oid = changeset.append("revision \##{id} of this document")
|
92
|
+
changeset.write('test/doot.txt', oid)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
database.commit(message: "unrelated commit") do |changeset|
|
97
|
+
oid = changeset.append("unrelated document")
|
98
|
+
changeset.write('test/unrelated.txt', oid)
|
99
|
+
end
|
100
|
+
|
101
|
+
expect(database.history('test/doot.txt').count).to be == 10
|
102
|
+
end
|
87
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaxo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|