git-ds 0.9.5.2 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/lib/git-ds/database.rb +13 -12
- data/lib/git-ds/index.rb +1 -0
- data/lib/git-ds/model/item.rb +3 -2
- data/lib/git-ds/repo.rb +8 -8
- data/tests/ut_database.rb +2 -0
- data/tests/ut_model.rb +32 -0
- data/tests/ut_user_group_model.rb +1 -1
- metadata +51 -28
data/ChangeLog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
2011-05-20 : mkfs <mkfs@thoughtgang.org>
|
2
|
+
* Fixed default-commmit bug in Database and Repo classes.
|
3
|
+
|
4
|
+
2011-04-19 : mkfs <mkfs@thoughtgang.org>
|
5
|
+
* Added proxy_property alias for ModelItem.link_property
|
6
|
+
|
1
7
|
2011-04-18 : mkfs <mkfs@thoughtgang.org>
|
2
8
|
* Bumped gem version to 0.9.5
|
3
9
|
* Added ModelItem.exist? class member
|
data/lib/git-ds/database.rb
CHANGED
@@ -97,10 +97,10 @@ NOTE: This does not create a commit! Ony the staging index changes.
|
|
97
97
|
def close(save=true)
|
98
98
|
raise InvalidDbError if @stale
|
99
99
|
|
100
|
-
if save &&
|
100
|
+
if save && staging?
|
101
101
|
self.staging.write
|
102
102
|
end
|
103
|
-
|
103
|
+
unstage
|
104
104
|
@stale = true
|
105
105
|
|
106
106
|
# TODO: remove all locks etc
|
@@ -160,7 +160,7 @@ See ExecCmd.
|
|
160
160
|
exec_in_staging(false, &block)
|
161
161
|
self.staging.write
|
162
162
|
ensure
|
163
|
-
self.
|
163
|
+
self.unstage
|
164
164
|
end
|
165
165
|
|
166
166
|
end
|
@@ -179,7 +179,7 @@ See Transaction.
|
|
179
179
|
self.staging
|
180
180
|
transaction_in_staging(false, &block)
|
181
181
|
ensure
|
182
|
-
self.
|
182
|
+
self.unstage
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
@@ -234,7 +234,7 @@ Wrapper for Grit::Repo#tree that checks if Database has been closed.
|
|
234
234
|
Generate a tag object for the most recent commit.
|
235
235
|
=end
|
236
236
|
def mark(msg)
|
237
|
-
tag_object(msg, commits.
|
237
|
+
tag_object(msg, commits.last.id)
|
238
238
|
end
|
239
239
|
|
240
240
|
=begin rdoc
|
@@ -247,21 +247,22 @@ See Database#transaction .
|
|
247
247
|
def branch_and_merge(name=next_branch_tag(), actor=nil, &block)
|
248
248
|
raise InvalidDbError if @stale
|
249
249
|
|
250
|
+
# Force a commit before the merge
|
251
|
+
# TODO: determine if this is really necessary
|
252
|
+
staging.sync
|
253
|
+
staging.commit('auto-commit before branch-and-merge', self.actor)
|
254
|
+
|
255
|
+
# ensure staging index is nil [in case branch name was re-used]
|
256
|
+
unstage
|
250
257
|
|
251
258
|
# save old actor
|
252
259
|
old_actor = self.actor
|
253
260
|
self.actor = actor if actor
|
254
261
|
|
255
|
-
|
256
|
-
saved_stage = (self.staging?) ? self.staging : nil
|
257
|
-
|
258
|
-
sha = commits.first ? commits.first.id : nil
|
262
|
+
sha = commits.last ? commits.last.id : nil
|
259
263
|
tag = create_branch(name, sha)
|
260
264
|
set_branch(tag, self.actor)
|
261
265
|
|
262
|
-
# ensure staging index is nil [in case branch name was re-used]
|
263
|
-
unstage
|
264
|
-
|
265
266
|
# execute block in a transaction
|
266
267
|
rv = true
|
267
268
|
begin
|
data/lib/git-ds/index.rb
CHANGED
data/lib/git-ds/model/item.rb
CHANGED
@@ -109,7 +109,7 @@ List all children of the ModelItem class inside parent_path.
|
|
109
109
|
end
|
110
110
|
|
111
111
|
=begin rdoc
|
112
|
-
Generate an ident from a Hash of arguments.
|
112
|
+
Generate an ident (String) from a Hash of arguments.
|
113
113
|
|
114
114
|
To be overridden by a modelitem class.
|
115
115
|
=end
|
@@ -270,6 +270,7 @@ ModelItems, use a ModelItem List of ProxyModelItemClass objects.
|
|
270
270
|
add_property ProxyProperty.new(name, cls, false, &block)
|
271
271
|
end
|
272
272
|
|
273
|
+
alias :proxy_property :link_property
|
273
274
|
|
274
275
|
=begin rdoc
|
275
276
|
Hash of properties associated with this MOdelItem class.
|
@@ -307,7 +308,7 @@ The GitDS::Model that contains the object.
|
|
307
308
|
def initialize_item(model, path)
|
308
309
|
@model = model
|
309
310
|
@path = path
|
310
|
-
@ident =
|
311
|
+
@ident = File.basename(path)
|
311
312
|
end
|
312
313
|
|
313
314
|
=begin rdoc
|
data/lib/git-ds/repo.rb
CHANGED
@@ -134,7 +134,7 @@ The canonical name of the tag is returned.
|
|
134
134
|
=end
|
135
135
|
def create_branch( tag=next_branch_tag(), sha=nil )
|
136
136
|
if not sha
|
137
|
-
sha = commits.
|
137
|
+
sha = commits.last.id
|
138
138
|
#sha = branches.first.commit.id if not sha
|
139
139
|
end
|
140
140
|
name = clean_tag(tag)
|
@@ -147,20 +147,20 @@ Sets the current branch to the specified tag. This changes the default
|
|
147
147
|
branch for all repo activity and sets HEAD.
|
148
148
|
=end
|
149
149
|
def set_branch( tag, actor=nil )
|
150
|
-
# allow creating of new branches
|
150
|
+
# allow creating of new branches via -b if they do not exist
|
151
151
|
opt = (is_head? tag) ? '' : '-b'
|
152
152
|
|
153
153
|
# Save staging index for current branch
|
154
|
-
@saved_stages[@current_branch] = self.staging if
|
154
|
+
@saved_stages[@current_branch] = self.staging if staging?
|
155
155
|
|
156
156
|
exec_git_cmd( "git checkout -q -m #{opt} '#{tag}'", actor )
|
157
157
|
|
158
158
|
# Synchronize staging index (required before merge)
|
159
159
|
unstage
|
160
|
-
self.staging.sync
|
161
160
|
|
162
161
|
# Update current_branch info and restore staging for branch
|
163
162
|
self.staging = @saved_stages[tag]
|
163
|
+
self.staging.sync if staging?
|
164
164
|
@current_branch = tag
|
165
165
|
end
|
166
166
|
|
@@ -210,7 +210,7 @@ Return the staging index for the repo.
|
|
210
210
|
=end
|
211
211
|
def staging
|
212
212
|
# TODO: mutex
|
213
|
-
@staging_index ||= StageIndex.
|
213
|
+
@staging_index ||= StageIndex.read(self)
|
214
214
|
end
|
215
215
|
|
216
216
|
=begin rdoc
|
@@ -227,7 +227,7 @@ Close staging index.
|
|
227
227
|
This discards all (non-committed) changes in the staging index.
|
228
228
|
=end
|
229
229
|
def unstage
|
230
|
-
self.staging=(nil)
|
230
|
+
self.staging=(nil) # yes, the self is required. not sure why.
|
231
231
|
end
|
232
232
|
|
233
233
|
=begin rdoc
|
@@ -261,7 +261,7 @@ Returns SHA of commit.
|
|
261
261
|
=end
|
262
262
|
def stage_and_commit(msg, actor=nil, &block)
|
263
263
|
stage(&block)
|
264
|
-
sha =
|
264
|
+
sha = staging.commit(msg, actor)
|
265
265
|
unstage
|
266
266
|
sha
|
267
267
|
end
|
@@ -401,7 +401,7 @@ Uses the staging index if it is active.
|
|
401
401
|
return @staging_index.sha
|
402
402
|
end
|
403
403
|
|
404
|
-
(self.commits.count > 0) ? self.commits.
|
404
|
+
(self.commits.count > 0) ? self.commits.last.tree.id : nil
|
405
405
|
end
|
406
406
|
|
407
407
|
=begin rdoc
|
data/tests/ut_database.rb
CHANGED
@@ -279,6 +279,8 @@ class TC_GitDatabaseTest < Test::Unit::TestCase
|
|
279
279
|
blob = index.current_tree./(name2)
|
280
280
|
assert_not_nil(blob, "nested db.exec did not create '#{name2}' in staging")
|
281
281
|
assert_equal(data2, blob.data, "BLOB data for '#{name2}' does not match")
|
282
|
+
|
283
|
+
@db.staging = nil
|
282
284
|
end
|
283
285
|
|
284
286
|
def test_branch
|
data/tests/ut_model.rb
CHANGED
@@ -342,8 +342,24 @@ class TC_GitModelTest < Test::Unit::TestCase
|
|
342
342
|
}
|
343
343
|
end
|
344
344
|
|
345
|
+
def model_save(tag, &block)
|
346
|
+
opts = { :name => tag, :msg => tag }
|
347
|
+
|
348
|
+
if block_given?
|
349
|
+
tag = @model.db.clean_tag(tag)
|
350
|
+
@model.branched_transaction(tag, &block)
|
351
|
+
# @model.branch = tag # set current branch to tag
|
352
|
+
@model.db.merge_branch(tag)
|
353
|
+
end
|
354
|
+
|
355
|
+
sha = @model.db.staging.commit(opts[:msg])
|
356
|
+
@model.db.tag_object(opts[:name], sha)
|
357
|
+
@model.db.unstage
|
358
|
+
end
|
359
|
+
|
345
360
|
def test_branch
|
346
361
|
num = @model.db.heads.count
|
362
|
+
@model.db.staging = nil
|
347
363
|
@model.branched_transaction {
|
348
364
|
index.add('tmp/1', '1')
|
349
365
|
}
|
@@ -358,6 +374,22 @@ class TC_GitModelTest < Test::Unit::TestCase
|
|
358
374
|
assert_equal(1,
|
359
375
|
@model.db.heads.select{|h| h.name == @model.db.clean_tag(name)}.count,
|
360
376
|
'Named BranchTransaction not present.')
|
377
|
+
|
378
|
+
# Model#save test
|
379
|
+
index = @model.db.staging
|
380
|
+
index.add('.stuff/canary', 'abcdef', false)
|
381
|
+
index.commit('done')
|
382
|
+
@model.db.unstage
|
383
|
+
|
384
|
+
model = @model
|
385
|
+
model_save('v1') do |opts|
|
386
|
+
model.db.stage.add('tmp/save_1', '1', true)
|
387
|
+
end
|
388
|
+
|
389
|
+
model_save('v2') do |opts|
|
390
|
+
model.db.stage.add('tmp/save_2', '2', true)
|
391
|
+
end
|
392
|
+
|
361
393
|
end
|
362
394
|
|
363
395
|
end
|
@@ -307,7 +307,7 @@ class TC_GitUserGroupModelTest < Test::Unit::TestCase
|
|
307
307
|
user_defs.each { |u| u[:obj].delete }
|
308
308
|
|
309
309
|
g.delete
|
310
|
-
assert( (not @model.exist? path) )
|
310
|
+
assert( (not @model.exist? path), 'path not deleted!' )
|
311
311
|
assert_equal(0, GroupModelItem.list(@model.root).count, '>0 Groups exist')
|
312
312
|
|
313
313
|
assert_raises(GitDS::InvalidModelItemError, 'Deleted item still usable') {
|
metadata
CHANGED
@@ -1,33 +1,46 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-ds
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 55
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 6
|
10
|
+
version: 0.9.6
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- TG Community
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2011-05-20 00:00:00 -04:00
|
13
19
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
16
22
|
name: grit
|
17
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
25
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 2
|
33
|
+
- 0
|
22
34
|
version: 2.2.0
|
23
35
|
type: :runtime
|
24
|
-
|
25
|
-
version_requirements: *20831860
|
36
|
+
version_requirements: *id001
|
26
37
|
description: A hierarchical datastore based on Git.
|
27
38
|
email: community@thoughtgang.org
|
28
39
|
executables: []
|
40
|
+
|
29
41
|
extensions: []
|
30
|
-
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
31
44
|
- doc/Examples.rdoc
|
32
45
|
- doc/examples/key_value/kv_get.rb
|
33
46
|
- doc/examples/key_value/kv_list.rb
|
@@ -56,7 +69,7 @@ extra_rdoc_files:
|
|
56
69
|
- doc/examples/test_suite/ts_add_bug.rb
|
57
70
|
- doc/examples/test_suite/ts_add_module_to_test.rb
|
58
71
|
- README.rdoc
|
59
|
-
files:
|
72
|
+
files:
|
60
73
|
- lib/git-ds.rb
|
61
74
|
- lib/git-ds/model.rb
|
62
75
|
- lib/git-ds/exec_cmd.rb
|
@@ -112,31 +125,41 @@ files:
|
|
112
125
|
- README.rdoc
|
113
126
|
has_rdoc: true
|
114
127
|
homepage: http://www.thoughtgang.org
|
115
|
-
licenses:
|
128
|
+
licenses:
|
116
129
|
- GPLv3
|
117
130
|
post_install_message:
|
118
131
|
rdoc_options: []
|
119
|
-
|
132
|
+
|
133
|
+
require_paths:
|
120
134
|
- lib
|
121
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
136
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 57
|
141
|
+
segments:
|
142
|
+
- 1
|
143
|
+
- 8
|
144
|
+
- 7
|
126
145
|
version: 1.8.7
|
127
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
147
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 3
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
version: "0"
|
133
155
|
requirements: []
|
156
|
+
|
134
157
|
rubyforge_project: git-db
|
135
|
-
rubygems_version: 1.
|
158
|
+
rubygems_version: 1.4.1
|
136
159
|
signing_key:
|
137
160
|
specification_version: 3
|
138
161
|
summary: Git-DS
|
139
|
-
test_files:
|
162
|
+
test_files:
|
140
163
|
- tests/ut_git_grit_equiv.rb
|
141
164
|
- tests/ut_user_group_model.rb
|
142
165
|
- tests/ut_model.rb
|