svn-fixture 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/svn-fixture.rb +4 -2
- data/lib/svn-fixture/directory.rb +7 -4
- data/lib/svn-fixture/repository.rb +12 -2
- data/lib/svn-fixture/revision.rb +2 -0
- data/spec/svn-fixture/directory_spec.rb +21 -1
- data/spec/svn-fixture/file_spec.rb +1 -1
- data/spec/svn-fixture/repository_spec.rb +14 -0
- data/spec/svn-fixture/revision_spec.rb +9 -1
- data/spec/svn-fixture_spec.rb +5 -5
- data/svn-fixture.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/svn-fixture.rb
CHANGED
@@ -8,7 +8,7 @@ require "svn/fs"
|
|
8
8
|
require "svn/repos"
|
9
9
|
|
10
10
|
module SvnFixture
|
11
|
-
VERSION = '0.
|
11
|
+
VERSION = '0.2.0'
|
12
12
|
|
13
13
|
CONFIG_DEFAULTS = {
|
14
14
|
:base_path => File.join(Dir.tmpdir, 'svn-fixture')
|
@@ -31,7 +31,9 @@ module SvnFixture
|
|
31
31
|
def svn_time(val)
|
32
32
|
return nil if val.nil?
|
33
33
|
val = Time.parse(val) unless val.respond_to?(:strftime)
|
34
|
-
val.
|
34
|
+
val = val.utc if val.respond_to?(:utc)
|
35
|
+
usec = val.respond_to?(:usec) ? val.usec : 0
|
36
|
+
val.strftime("%Y-%m-%dT%H:%M:%S.") + sprintf('%06dZ', usec)
|
35
37
|
end
|
36
38
|
|
37
39
|
# Return a Date or Time formatted as expected by
|
@@ -90,10 +90,13 @@ module SvnFixture
|
|
90
90
|
|
91
91
|
# Set a property for the Directory
|
92
92
|
# (see http://svnbook.red-bean.com/en/1.1/ch07s02.html):
|
93
|
-
#
|
94
|
-
#
|
95
|
-
|
96
|
-
|
93
|
+
#
|
94
|
+
# ==== Parameters
|
95
|
+
# name<String>:: The property name (must be "human-readable text")
|
96
|
+
# value<String>:: The value of the property.
|
97
|
+
# recurse<True, False>:: Apply this property to descendants?
|
98
|
+
def prop(name, value, recurse = false)
|
99
|
+
@ctx.propset(name, SvnFixture.svn_prop(value), @path[0..-2], recurse)
|
97
100
|
end
|
98
101
|
end
|
99
102
|
end
|
@@ -2,7 +2,7 @@ module SvnFixture
|
|
2
2
|
# Repository sets up the repository and is reponsible for checkouts and
|
3
3
|
# the actual commit(s). No actual work is done until +commit+ is called.
|
4
4
|
class Repository
|
5
|
-
attr_reader :repos, :ctx, :
|
5
|
+
attr_reader :repos, :ctx, :revisions
|
6
6
|
|
7
7
|
class << self
|
8
8
|
# Get an SvnFixture::Repository by name. If not found, it creates a new
|
@@ -153,9 +153,19 @@ module SvnFixture
|
|
153
153
|
self.class.repositories.delete(@name)
|
154
154
|
end
|
155
155
|
|
156
|
+
# Absolute path to working copy
|
157
|
+
def wc_path
|
158
|
+
::File.expand_path(@wc_path)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Absolute path to repository
|
162
|
+
def repos_path
|
163
|
+
::File.expand_path(@repos_path)
|
164
|
+
end
|
165
|
+
|
156
166
|
# URI (file://...) for accessing the Repository
|
157
167
|
def uri
|
158
|
-
"file://" +
|
168
|
+
"file://" + self.repos_path
|
159
169
|
end
|
160
170
|
|
161
171
|
private
|
data/lib/svn-fixture/revision.rb
CHANGED
@@ -50,6 +50,7 @@ module SvnFixture
|
|
50
50
|
# Only argument is an instance of SvnFixture::Repository that is the
|
51
51
|
# Repository to which this revision is committed.
|
52
52
|
def commit(repo)
|
53
|
+
repo.ctx.update(repo.wc_path) # Ensure everything up-to-date
|
53
54
|
root = Directory.new(repo.ctx, repo.wc_path)
|
54
55
|
root.instance_eval(&@block) if @block
|
55
56
|
ci = repo.ctx.ci(repo.wc_path)
|
@@ -59,6 +60,7 @@ module SvnFixture
|
|
59
60
|
repo.repos.fs.set_prop('svn:author', @author, rev) if @author
|
60
61
|
repo.repos.fs.set_prop('svn:date', @date, rev) if @date
|
61
62
|
@revprops.each do | key, val |
|
63
|
+
val = SvnFixture.svn_time(val) if val.respond_to?(:strftime)
|
62
64
|
repo.repos.fs.set_prop(key.to_s, val.to_s, rev)
|
63
65
|
end
|
64
66
|
else
|
@@ -184,8 +184,28 @@ describe SvnFixture::Directory do
|
|
184
184
|
'New Value'
|
185
185
|
end
|
186
186
|
|
187
|
+
it 'should not set a property recursively by default' do
|
188
|
+
@dir.prop('prop:name', 'Prop Value')
|
189
|
+
rev = @ctx.ci(@wc_path).revision
|
190
|
+
@ctx.propget('prop:name', @path, rev)[@full_repos_path].should ==
|
191
|
+
'Prop Value'
|
192
|
+
@ctx.propget('prop:name', @path + "/subdir", rev)[@full_repos_path + "/subdir"].should be_nil
|
193
|
+
@ctx.propget('prop:name', @path + "/file.txt", rev)[@full_repos_path + "/file.txt"].should be_nil
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should set a property recursively if told to' do
|
197
|
+
@dir.prop('prop:name', 'Prop Value', true)
|
198
|
+
rev = @ctx.ci(@wc_path).revision
|
199
|
+
@ctx.propget('prop:name', @path, rev)[@full_repos_path].should ==
|
200
|
+
'Prop Value'
|
201
|
+
@ctx.propget('prop:name', @path + "/subdir", rev)[@full_repos_path + "/subdir"].should ==
|
202
|
+
'Prop Value'
|
203
|
+
@ctx.propget('prop:name', @path + "/file.txt", rev)[@full_repos_path + "/file.txt"].should ==
|
204
|
+
'Prop Value'
|
205
|
+
end
|
206
|
+
|
187
207
|
it 'should format a Time correctly' do
|
188
|
-
@dir.prop('prop:timeval', Time.parse('2009-06-18 14:00'))
|
208
|
+
@dir.prop('prop:timeval', Time.parse('2009-06-18 14:00 UTC'))
|
189
209
|
rev = @ctx.ci(@wc_path).revision
|
190
210
|
@ctx.propget('prop:timeval', @path, rev)[@full_repos_path].should ==
|
191
211
|
'2009-06-18T14:00:00.000000Z'
|
@@ -49,7 +49,7 @@ describe SvnFixture::File do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should format a Time correctly' do
|
52
|
-
@file.prop('prop:timeval', Time.parse('2009-06-18 14:00'))
|
52
|
+
@file.prop('prop:timeval', Time.parse('2009-06-18 14:00 UTC'))
|
53
53
|
rev = @ctx.ci(@wc_path).revision
|
54
54
|
@ctx.propget('prop:timeval', @path, rev)[@full_repos_path].should ==
|
55
55
|
'2009-06-18T14:00:00.000000Z'
|
@@ -321,6 +321,20 @@ describe SvnFixture::Repository do
|
|
321
321
|
end
|
322
322
|
end
|
323
323
|
|
324
|
+
describe '#wc_path' do
|
325
|
+
it 'should be the absolute path to the working copy' do
|
326
|
+
r = @klass.new('test1', '/test/repos', '/test/wc')
|
327
|
+
r.wc_path.should == '/test/wc'
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe '#repos_path' do
|
332
|
+
it 'should be the absolute path to the repository' do
|
333
|
+
r = @klass.new('test1', '/test/repos', '/test/wc')
|
334
|
+
r.repos_path.should == '/test/repos'
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
324
338
|
describe '#uri' do
|
325
339
|
it 'should return the uri for accessing the Repository' do
|
326
340
|
r = @klass.new('test1', '/test/path')
|
@@ -29,7 +29,14 @@ describe SvnFixture::Revision do
|
|
29
29
|
@repos = SvnFixture::repo('file_test').checkout
|
30
30
|
# @repos_path = @repos.instance_variable_get(:@repos_path)
|
31
31
|
@wc_path = @repos.instance_variable_get(:@wc_path)
|
32
|
-
|
32
|
+
options = {
|
33
|
+
:author => 'author',
|
34
|
+
:date => Time.parse('2009-01-01 12:00:00Z'),
|
35
|
+
'other:revprop' => 20,
|
36
|
+
'other:timeprop' => Time.parse('2009-01-01 12:00:01.0912Z')
|
37
|
+
}
|
38
|
+
|
39
|
+
@rev = @klass.new(1, 'msg', options) do
|
33
40
|
dir('test-dir')
|
34
41
|
end
|
35
42
|
@rev.commit(@repos)
|
@@ -63,6 +70,7 @@ describe SvnFixture::Revision do
|
|
63
70
|
|
64
71
|
it 'should set additional revprops if given' do
|
65
72
|
@fs.prop('other:revprop', 1).should == '20'
|
73
|
+
@fs.prop('other:timeprop', 1).should == '2009-01-01T12:00:01.091200Z'
|
66
74
|
end
|
67
75
|
|
68
76
|
it 'should print warning if no changes' do
|
data/spec/svn-fixture_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe SvnFixture do
|
|
4
4
|
|
5
5
|
describe '.svn_time' do
|
6
6
|
it 'should format as expected by ::Svn::Client::Context#propset' do
|
7
|
-
t = Time.parse('2009-06-18 13:00')
|
7
|
+
t = Time.parse('2009-06-18 13:00 UTC')
|
8
8
|
SvnFixture.svn_time(t).should == '2009-06-18T13:00:00.000000Z'
|
9
9
|
|
10
10
|
d = Date.parse('2009-06-19')
|
@@ -12,8 +12,8 @@ describe SvnFixture do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should parse the #to_s value if not a Date or Time or nil' do
|
15
|
-
t = '2009-06-18 13:00'
|
16
|
-
SvnFixture.svn_time(t).should == '2009-06-18T13:00:
|
15
|
+
t = '2009-06-18 13:00:01.002 UTC'
|
16
|
+
SvnFixture.svn_time(t).should == '2009-06-18T13:00:01.002000Z'
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should return nil if value is nil' do
|
@@ -23,8 +23,8 @@ describe SvnFixture do
|
|
23
23
|
|
24
24
|
describe '.svn_prop' do
|
25
25
|
it 'should format Time/Date as expected by ::Svn::Client::Context#propset' do
|
26
|
-
t = Time.parse('2009-06-18 13:00')
|
27
|
-
SvnFixture.svn_prop(t).should == '2009-06-18T13:00:
|
26
|
+
t = Time.parse('2009-06-18 13:00:01.002111 UTC')
|
27
|
+
SvnFixture.svn_prop(t).should == '2009-06-18T13:00:01.002111Z'
|
28
28
|
|
29
29
|
d = Date.parse('2009-06-19')
|
30
30
|
SvnFixture.svn_prop(d).should == '2009-06-19T00:00:00.000000Z'
|
data/svn-fixture.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{svn-fixture}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jared Morgan"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-18}
|
13
13
|
s.description = %q{svn-fixture simplifies creating (or updating) a Subversion repository. It is
|
14
14
|
designed to be used in tests that require a Subversion repo, but can also be
|
15
15
|
used to initialize a repository according to some template. svn-fixture depends
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svn-fixture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Morgan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-18 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|