Class: StoreAgent::VersionManager::RuggedGit
Overview
Instance Attribute Summary
#workspace
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize
Class Method Details
.reserved_filenames ⇒ Object
23
24
25
|
# File 'lib/store_agent/version_manager/rugged_git.rb', line 23
def self.reserved_filenames
%w(.git .keep)
end
|
Instance Method Details
#add(*paths) ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/store_agent/version_manager/rugged_git.rb', line 35
def add(*paths)
super do
FileUtils.touch(paths)
paths.flatten.each do |path|
oid = Rugged::Blob.from_workdir(repository, relative_path(path))
repository.index.add(relative_path(path))
end
end
end
|
#init ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/store_agent/version_manager/rugged_git.rb', line 27
def init
super do
Rugged::Repository.init_at(".")
repository.config["user.name"] ||= "test_user"
repository.config["user.email"] ||= "[email protected]"
end
end
|
#read(path: "", revision: nil) ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/store_agent/version_manager/rugged_git.rb', line 76
def read(path: "", revision: nil)
if path.end_with?("/")
read_directory(path: path, revision: revision)
else
read_file(path: path, revision: revision)
end
end
|
#remove(*paths, directory: false) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/store_agent/version_manager/rugged_git.rb', line 45
def remove(*paths, directory: false)
super do
paths.flatten.each do |path|
if directory
repository.index.remove_dir(relative_path(path))
else
repository.index.remove(relative_path(path))
end
end
end
end
|
#revisions(path = "*") ⇒ Object
84
85
86
|
# File 'lib/store_agent/version_manager/rugged_git.rb', line 84
def revisions(path = "*")
logs(path).map(&:oid)
end
|
#transaction(message) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/store_agent/version_manager/rugged_git.rb', line 57
def transaction(message)
if @transaction
yield
else
begin
@transaction = true
super do
yield
end
commit(message)
rescue => e
repository.reset("HEAD", :hard)
raise e
ensure
@transaction = false
end
end
end
|