Dahistory 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.write(File.join(history, backup_basename), content)
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
- if @git
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
 
@@ -1,3 +1,3 @@
1
1
  class Dahistory
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Dahistory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: