Dahistory 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,19 +100,24 @@ class Dahistory
100
100
  standard = content.gsub("\r", '')
101
101
 
102
102
  old = self.class.find_file_copy file, dirs
103
+ in_pending = self.class.find_file_copy file, pending_dir
103
104
 
104
- if !old
105
- File.write(backup_file, content) unless self.class.find_file_copy(file, pending_dir)
105
+ if !old
106
106
 
107
-
108
- if @git
109
- Exit_Zero "git add #{backup_file}"
110
- Exit_Zero %! git commit -m "Backup: #{backup_file}"!
111
- end
112
-
113
- if @git.is_a?(String)
114
- Exit_Zero %! git push #{@git} !
115
- end
107
+ if !in_pending
108
+
109
+ File.write(backup_file, content)
110
+
111
+ if @git
112
+ Exit_Zero "git add #{backup_file}"
113
+ Exit_Zero %! git commit -m "Backup: #{backup_file}"!
114
+ end
115
+
116
+ if @git.is_a?(String)
117
+ Exit_Zero %! git push #{@git} !
118
+ end
119
+
120
+ end # === if !in_pending
116
121
 
117
122
  on_raise_pending.call if on_raise_pending
118
123
  raise Pending, backup_file
@@ -1,3 +1,3 @@
1
1
  class Dahistory
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -87,6 +87,22 @@ end # === Dahistory: existing file in ./history
87
87
  describe "Dahistory :git_add_commit" do
88
88
 
89
89
  behaves_like "git"
90
+
91
+ it "does not add file to working tree if already pending" do
92
+ Dir.chdir(@proj) {
93
+
94
+ File.write @file, @file
95
+ File.write(@file.sub('files', 'pending'), @file)
96
+ target = `git status`
97
+ lambda {
98
+ Dahistory { |o|
99
+ o.file @file
100
+ o.git_add_commit
101
+ }
102
+ }.should.raise Dahistory::Pending
103
+ `git status`.should == target
104
+ }
105
+ end
90
106
 
91
107
  it "adds backup file as a commit" do
92
108
  target = nil
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: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-11 00:00:00.000000000 Z
12
+ date: 2012-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon