silo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/Changelog.md +13 -0
- data/LICENSE +25 -0
- data/README.md +153 -0
- data/Rakefile +45 -0
- data/bin/silo +9 -0
- data/gemspec.yml +29 -0
- data/lib/core_ext/pathname.rb +20 -0
- data/lib/silo.rb +20 -0
- data/lib/silo/cli.rb +167 -0
- data/lib/silo/errors.rb +58 -0
- data/lib/silo/remote/base.rb +33 -0
- data/lib/silo/remote/git.rb +50 -0
- data/lib/silo/repository.rb +366 -0
- data/lib/silo/version.rb +11 -0
- data/test/data/file1 +0 -0
- data/test/data/file2 +0 -0
- data/test/data/subdir1/file1 +0 -0
- data/test/data/subdir2/file2 +0 -0
- data/test/helper.rb +13 -0
- data/test/test_repository.rb +204 -0
- metadata +167 -0
data/lib/silo/version.rb
ADDED
data/test/data/file1
ADDED
File without changes
|
data/test/data/file2
ADDED
File without changes
|
File without changes
|
File without changes
|
data/test/helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2010, Sebastian Staudt
|
5
|
+
|
6
|
+
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
7
|
+
$: << File.dirname(__FILE__)
|
8
|
+
require 'silo'
|
9
|
+
include Silo
|
10
|
+
|
11
|
+
require 'rubygems'
|
12
|
+
require 'shoulda'
|
13
|
+
|
@@ -0,0 +1,204 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2010-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
require 'core_ext/pathname'
|
10
|
+
|
11
|
+
class TestRepository < Test::Unit::TestCase
|
12
|
+
|
13
|
+
context 'A new backup repository' do
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@dir = Dir.mktmpdir
|
17
|
+
Dir.rmdir @dir
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'contain a bare Git repository prepared for Silo by default' do
|
21
|
+
repo = Repository.new @dir
|
22
|
+
assert repo.git.is_a? Grit::Repo
|
23
|
+
assert repo.prepared?
|
24
|
+
assert_equal 1, repo.git.commits.size
|
25
|
+
assert_equal 'Enabled Silo for this repository', repo.git.commits.first.message
|
26
|
+
end
|
27
|
+
|
28
|
+
should 'contain a plain Git repository when option :prepare is false' do
|
29
|
+
repo = Repository.new @dir, :prepare => false
|
30
|
+
assert repo.git.is_a? Grit::Repo
|
31
|
+
assert !repo.prepared?
|
32
|
+
assert_equal 0, repo.git.commits.size
|
33
|
+
end
|
34
|
+
|
35
|
+
should 'fail when option :create is false and the target directory does not exist' do
|
36
|
+
assert_raise Grit::NoSuchPathError do
|
37
|
+
Repository.new @dir, :create => false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
should 'fail if the target directory exists but is not an empty Git repository' do
|
42
|
+
assert_raise Grit::InvalidGitRepositoryError do
|
43
|
+
Repository.new File.dirname(__FILE__)
|
44
|
+
end
|
45
|
+
|
46
|
+
assert_raise InvalidRepositoryError do
|
47
|
+
Repository.new File.join(File.dirname(File.dirname(__FILE__)), '.git')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'An existing backup repository' do
|
54
|
+
|
55
|
+
setup do
|
56
|
+
@repo_dir = Dir.mktmpdir
|
57
|
+
`git init --bare #{@repo_dir}`
|
58
|
+
ENV['GIT_DIR'] = @repo_dir
|
59
|
+
ENV['GIT_WORK_TREE'] = File.expand_path '.'
|
60
|
+
FileUtils.touch '.silo'
|
61
|
+
`git add .silo`
|
62
|
+
`git commit -m "Enabled Silo for this repository"`
|
63
|
+
ENV['GIT_WORK_TREE'] = nil
|
64
|
+
@repo = Repository.new @repo_dir
|
65
|
+
end
|
66
|
+
|
67
|
+
should 'contain a Git repository' do
|
68
|
+
assert @repo.git.is_a? Grit::Repo
|
69
|
+
end
|
70
|
+
|
71
|
+
should 'be prepared' do
|
72
|
+
assert_equal 1, @repo.git.commits.size
|
73
|
+
assert @repo.prepared?
|
74
|
+
end
|
75
|
+
|
76
|
+
should 'not allow re-preparing the repository' do
|
77
|
+
assert_raise AlreadyPreparedError do
|
78
|
+
@repo.prepare
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
teardown do
|
83
|
+
FileUtils.rm_rf [@repo_dir, '.silo'], :secure => true
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'Backing up and restoring' do
|
89
|
+
|
90
|
+
setup do
|
91
|
+
@data_dir = Pathname.new(File.dirname(__FILE__))/'data'
|
92
|
+
@repo = Repository.new Dir.mktmpdir
|
93
|
+
@old_pwd = Dir.pwd
|
94
|
+
@target_dir = Pathname.new Dir.mktmpdir
|
95
|
+
@work_dir = Pathname.new Dir.mktmpdir
|
96
|
+
Dir.chdir @work_dir
|
97
|
+
end
|
98
|
+
|
99
|
+
should 'save single files correctly' do
|
100
|
+
@repo.add @data_dir/'file1'
|
101
|
+
@repo.add @data_dir/'file2'
|
102
|
+
|
103
|
+
assert_equal 3, @repo.git.commits.size
|
104
|
+
assert (@repo.git.tree/('file1')).is_a? Grit::Blob
|
105
|
+
assert (@repo.git.tree/('file2')).is_a? Grit::Blob
|
106
|
+
assert_equal "Added file #{@data_dir + 'file1'} into '/'", @repo.git.commits[1].message
|
107
|
+
assert_equal "Added file #{@data_dir + 'file2'} into '/'", @repo.git.commits[2].message
|
108
|
+
end
|
109
|
+
|
110
|
+
should 'save directory trees correctly' do
|
111
|
+
@repo.add @data_dir
|
112
|
+
|
113
|
+
assert_equal 2, @repo.git.commits.size
|
114
|
+
assert_equal "Added directory #{@data_dir} into '/'", @repo.git.commits[1].message
|
115
|
+
assert (@repo.git.tree/('data/file1')).is_a? Grit::Blob
|
116
|
+
assert (@repo.git.tree/('data/file2')).is_a? Grit::Blob
|
117
|
+
assert (@repo.git.tree/('data/subdir1')).is_a? Grit::Tree
|
118
|
+
assert (@repo.git.tree/('data/subdir1/file1')).is_a? Grit::Blob
|
119
|
+
assert (@repo.git.tree/('data/subdir2')).is_a? Grit::Tree
|
120
|
+
assert (@repo.git.tree/('data/subdir2/file2')).is_a? Grit::Blob
|
121
|
+
end
|
122
|
+
|
123
|
+
should 'save single files correctly into a prefix directory' do
|
124
|
+
@repo.add @data_dir/'file1', 'prefix'
|
125
|
+
@repo.add @data_dir/'file2', 'prefix'
|
126
|
+
|
127
|
+
assert_equal 3, @repo.git.commits.size
|
128
|
+
assert (@repo.git.tree/('prefix/file1')).is_a? Grit::Blob
|
129
|
+
assert (@repo.git.tree/('prefix/file2')).is_a? Grit::Blob
|
130
|
+
assert_equal "Added file #{@data_dir + 'file1'} into 'prefix'", @repo.git.commits[1].message
|
131
|
+
assert_equal "Added file #{@data_dir + 'file2'} into 'prefix'", @repo.git.commits[2].message
|
132
|
+
end
|
133
|
+
|
134
|
+
should 'save directory trees correctly into a prefix directory' do
|
135
|
+
@repo.add @data_dir, 'prefix'
|
136
|
+
|
137
|
+
assert_equal 2, @repo.git.commits.size
|
138
|
+
assert_equal "Added directory #{@data_dir} into 'prefix'", @repo.git.commits[1].message
|
139
|
+
assert (@repo.git.tree/('prefix/data/file1')).is_a? Grit::Blob
|
140
|
+
assert (@repo.git.tree/('prefix/data/file2')).is_a? Grit::Blob
|
141
|
+
assert (@repo.git.tree/('prefix/data/subdir1')).is_a? Grit::Tree
|
142
|
+
assert (@repo.git.tree/('prefix/data/subdir1/file1')).is_a? Grit::Blob
|
143
|
+
assert (@repo.git.tree/('prefix/data/subdir2')).is_a? Grit::Tree
|
144
|
+
assert (@repo.git.tree/('prefix/data/subdir2/file2')).is_a? Grit::Blob
|
145
|
+
end
|
146
|
+
|
147
|
+
should 'restore single files correctly' do
|
148
|
+
@repo.add @data_dir
|
149
|
+
@repo.add @data_dir/'file1'
|
150
|
+
@repo.restore 'file1'
|
151
|
+
@repo.restore 'data/file2', @target_dir
|
152
|
+
|
153
|
+
assert File.exist? @work_dir/'file1'
|
154
|
+
assert File.exist? @target_dir/'file2'
|
155
|
+
end
|
156
|
+
|
157
|
+
should 'restore directory trees correctly' do
|
158
|
+
@repo.add @data_dir
|
159
|
+
@repo.restore 'data'
|
160
|
+
@repo.restore 'data/subdir1', @target_dir
|
161
|
+
|
162
|
+
assert File.exist? @work_dir/'data/file1'
|
163
|
+
assert File.exist? @work_dir/'data/file2'
|
164
|
+
assert File.exist? @work_dir/'data/subdir1/file1'
|
165
|
+
assert File.exist? @work_dir/'data/subdir2/file2'
|
166
|
+
|
167
|
+
assert File.exist? @target_dir/'subdir1'
|
168
|
+
assert File.exist? @target_dir/'subdir1/file1'
|
169
|
+
end
|
170
|
+
|
171
|
+
should 'purge files and directories correctly' do
|
172
|
+
@repo.add @data_dir
|
173
|
+
@repo.add @data_dir/'file1'
|
174
|
+
|
175
|
+
@repo.purge 'data/file1'
|
176
|
+
assert_equal 3, @repo.git.commits.size
|
177
|
+
assert (@repo.git.tree/'data/file1').nil?
|
178
|
+
|
179
|
+
@repo.purge 'data'
|
180
|
+
assert_equal 2, @repo.git.commits.size
|
181
|
+
assert (@repo.git.tree/'data').nil?
|
182
|
+
|
183
|
+
@repo.purge 'file1'
|
184
|
+
assert_equal 1, @repo.git.commits.size
|
185
|
+
assert (@repo.git.tree/'file1').nil?
|
186
|
+
|
187
|
+
@repo.add @data_dir
|
188
|
+
@repo.add @data_dir/'file1'
|
189
|
+
|
190
|
+
@repo.purge 'data', false
|
191
|
+
@repo.purge 'file1', false
|
192
|
+
assert_equal 3, @repo.git.commits.size
|
193
|
+
assert (@repo.git.tree/'data').nil?
|
194
|
+
assert (@repo.git.tree/'file1').nil?
|
195
|
+
end
|
196
|
+
|
197
|
+
teardown do
|
198
|
+
Dir.chdir @old_pwd
|
199
|
+
FileUtils.rm_rf [@repo.path, @work_dir, @target_dir], :secure => true
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: silo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Sebastian Staudt
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-30 00:00:00 +01:00
|
19
|
+
default_executable: silo
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rubikon
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 6
|
33
|
+
- 0
|
34
|
+
version: 0.6.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: grit
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 29
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 4
|
49
|
+
- 1
|
50
|
+
version: 2.4.1
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: shoulda
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 37
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 11
|
65
|
+
- 3
|
66
|
+
version: 2.11.3
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ore-tasks
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 19
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 3
|
81
|
+
- 0
|
82
|
+
version: 0.3.0
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: yard
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 15
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
- 6
|
97
|
+
- 4
|
98
|
+
version: 0.6.4
|
99
|
+
type: :development
|
100
|
+
version_requirements: *id005
|
101
|
+
description: With Silo you can backup arbitrary files into one or more Git repositories and take advantage of Git's compression, speed and other features. No Git knowledge needed.
|
102
|
+
email: koraktor@gmail.com
|
103
|
+
executables:
|
104
|
+
- silo
|
105
|
+
extensions: []
|
106
|
+
|
107
|
+
extra_rdoc_files:
|
108
|
+
- Changelog.md
|
109
|
+
- LICENSE
|
110
|
+
files:
|
111
|
+
- lib/silo/remote/git.rb
|
112
|
+
- gemspec.yml
|
113
|
+
- lib/silo/repository.rb
|
114
|
+
- lib/core_ext/pathname.rb
|
115
|
+
- .yardopts
|
116
|
+
- test/data/file1
|
117
|
+
- test/data/file2
|
118
|
+
- bin/silo
|
119
|
+
- LICENSE
|
120
|
+
- test/data/subdir2/file2
|
121
|
+
- test/data/subdir1/file1
|
122
|
+
- lib/silo/version.rb
|
123
|
+
- Rakefile
|
124
|
+
- README.md
|
125
|
+
- test/test_repository.rb
|
126
|
+
- Changelog.md
|
127
|
+
- lib/silo/remote/base.rb
|
128
|
+
- lib/silo/errors.rb
|
129
|
+
- lib/silo.rb
|
130
|
+
- test/helper.rb
|
131
|
+
- lib/silo/cli.rb
|
132
|
+
has_rdoc: true
|
133
|
+
homepage: http://koraktor.de/silo
|
134
|
+
licenses:
|
135
|
+
- BSD
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
hash: 3
|
156
|
+
segments:
|
157
|
+
- 0
|
158
|
+
version: "0"
|
159
|
+
requirements:
|
160
|
+
- git >= 1.6
|
161
|
+
rubyforge_project: silo
|
162
|
+
rubygems_version: 1.4.2
|
163
|
+
signing_key:
|
164
|
+
specification_version: 3
|
165
|
+
summary: A command-line utility and API for Git-based backups
|
166
|
+
test_files:
|
167
|
+
- test/test_repository.rb
|