Dahistory 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Dahistory.rb +14 -9
- data/lib/Dahistory/version.rb +1 -1
- data/spec/tests/Dashistory.rb +18 -0
- metadata +1 -1
data/lib/Dahistory.rb
CHANGED
@@ -103,6 +103,16 @@ class Dahistory
|
|
103
103
|
@git = args
|
104
104
|
end
|
105
105
|
|
106
|
+
def git_it path
|
107
|
+
return false unless @git
|
108
|
+
Exit_Zero "git add #{path}"
|
109
|
+
Exit_Zero %! git commit -m "Backup: #{backup_file}"!
|
110
|
+
|
111
|
+
if @git.is_a?(String)
|
112
|
+
Exit_Zero %! git push #{@git} !
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
106
116
|
def save
|
107
117
|
|
108
118
|
content = File.read(file)
|
@@ -115,7 +125,9 @@ class Dahistory
|
|
115
125
|
return true if in_history
|
116
126
|
|
117
127
|
if in_dirs
|
118
|
-
File.
|
128
|
+
path = File.join(history, backup_basename)
|
129
|
+
File.write(path, content)
|
130
|
+
git_it path
|
119
131
|
return true
|
120
132
|
end
|
121
133
|
|
@@ -123,14 +135,7 @@ class Dahistory
|
|
123
135
|
|
124
136
|
File.write(backup_file, content)
|
125
137
|
|
126
|
-
|
127
|
-
Exit_Zero "git add #{backup_file}"
|
128
|
-
Exit_Zero %! git commit -m "Backup: #{backup_file}"!
|
129
|
-
end
|
130
|
-
|
131
|
-
if @git.is_a?(String)
|
132
|
-
Exit_Zero %! git push #{@git} !
|
133
|
-
end
|
138
|
+
git_it backup_file
|
134
139
|
|
135
140
|
end # === if !in_pending
|
136
141
|
|
data/lib/Dahistory/version.rb
CHANGED
data/spec/tests/Dashistory.rb
CHANGED
@@ -147,6 +147,24 @@ describe "Dahistory :git_add_commit" do
|
|
147
147
|
.out[target].should == target
|
148
148
|
}
|
149
149
|
end
|
150
|
+
|
151
|
+
it "adds backup file as a commit if in source dir" do
|
152
|
+
target = nil
|
153
|
+
|
154
|
+
Dir.chdir(@proj) {
|
155
|
+
File.write @file, @file
|
156
|
+
|
157
|
+
Dahistory { |o|
|
158
|
+
o.file @file
|
159
|
+
o.dirs "./files"
|
160
|
+
o.git_add_commit
|
161
|
+
target = "Backup: #{o.backup_file}"
|
162
|
+
}
|
163
|
+
|
164
|
+
Exit_Zero('git log -n 1 --oneline --decorate=short')
|
165
|
+
.out[target].should == target
|
166
|
+
}
|
167
|
+
end
|
150
168
|
|
151
169
|
end # === Dahistory :git_add_commit
|
152
170
|
|