waggit 0.0.011 → 0.0.012

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git.rb +1 -0
  3. data/lib/waggit.rb +43 -18
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb6f12cca80872d6f3abf76d06d91e70e9f37b53
4
- data.tar.gz: 6422510225fd24c204c13d58872a5e3aed54ce08
3
+ metadata.gz: 4e12a2d433f99bcae12d0035806d30f0a7a97948
4
+ data.tar.gz: 7ac23667b9bf78b81ae412a641aaf87b26b6485b
5
5
  SHA512:
6
- metadata.gz: ead58380a6ad904aa0aa36c5239345ea51f2e7ffdd0da5d9ced0ea9d24dd616c1b17f5aa5ae255c41b2815fa3001bc3d526e42e80a25db249a5e9d603d0e7c24
7
- data.tar.gz: 7b4e59fe4bc7211233d0cb227f2d3c41c0156fb96188b507cb292905e6498d34e4dfd19fb54c257f961bd1d97cca9c635555ae1eaf1dfc67c45ef276bddc1f60
6
+ metadata.gz: 65a6b2ecac24da89aad38c830bb2dd0d98ca331ac2de43c322553ccf6b5cf52f4cde6d907c54b10e6a9cfbf7f2f5a9b9ce9a9220214df8329e78bb417d0ea4d6
7
+ data.tar.gz: cf42c69b002a1acc8cc955779960f5e9e684a471af9faf49416688b1aabe362f174639823179fdc9394e5d57198169d53744c40b8feae59b337a6973738c9128
data/lib/git.rb CHANGED
@@ -13,6 +13,7 @@ module Git
13
13
  # Git commit, will prompt user for commit message
14
14
  #
15
15
  def self.commit_prompt()
16
+ return unless has_changes?
16
17
  puts "Enter a git commit message:"
17
18
  message = $stdin.gets.chomp
18
19
  self.commit(message)
data/lib/waggit.rb CHANGED
@@ -52,11 +52,13 @@ module Waggit
52
52
  # Push local changes to wagon, ignoring git.
53
53
  #
54
54
  def self.forcepush(options)
55
- dir = get_waggit_dir
56
- if dir
57
- Dir.chdir(dir) do
58
- Files.clean_css
59
- Wagon.push(options)
55
+ if confirm_push
56
+ dir = get_waggit_dir
57
+ if dir
58
+ Dir.chdir(dir) do
59
+ Files.clean_css
60
+ Wagon.push(options)
61
+ end
60
62
  end
61
63
  end
62
64
  end
@@ -64,19 +66,21 @@ module Waggit
64
66
  # Commit local changes and keep in sync with git, then push to wagon.
65
67
  #
66
68
  def self.push(options)
67
- dir = get_waggit_dir
68
- if dir
69
- Dir.chdir(dir) do
70
- Git.add_all
71
- Git.commit_prompt
72
- Files.clean_css
73
- if Git.has_changes?
69
+ if confirm_push
70
+ dir = get_waggit_dir
71
+ if dir
72
+ Dir.chdir(dir) do
74
73
  Git.add_all
75
- Git.commit "cleaned css"
74
+ Git.commit_prompt
75
+ Files.clean_css
76
+ if Git.has_changes?
77
+ Git.add_all
78
+ Git.commit "cleaned css"
79
+ end
80
+ Git.pull
81
+ Git.push
82
+ Wagon.push(options)
76
83
  end
77
- Git.pull
78
- Git.push
79
- Wagon.push(options)
80
84
  end
81
85
  end
82
86
  end
@@ -114,7 +118,7 @@ module Waggit
114
118
  Git.delete_wagon
115
119
  Git.delete_local
116
120
  rescue Exception
117
- "Pull aborted, switching back to master branch"
121
+ puts "Pull aborted, switching back to master branch"
118
122
  Git.checkout_master
119
123
  raise
120
124
  end
@@ -166,7 +170,7 @@ module Waggit
166
170
 
167
171
  Wagon.push(options)
168
172
  rescue Exception
169
- "Sync aborted, switching back to master branch"
173
+ puts "Sync aborted, switching back to master branch"
170
174
  Git.checkout_master
171
175
  raise
172
176
  end
@@ -174,4 +178,25 @@ module Waggit
174
178
  end
175
179
  end
176
180
 
181
+ # Since pushing local content can overwrite remote content
182
+ # we want the user to confirm the operation
183
+ #
184
+ def self.confirm_push()
185
+ puts "Performing this operation will overwrite content on the server."
186
+ response = nil
187
+ while response.nil?
188
+ puts "Do you want to continue? [y/n]"
189
+ response = gets.chomp.downcase
190
+ case response
191
+ when "y", "yes"
192
+ return true
193
+ when "n", "no"
194
+ return false
195
+ else
196
+ puts "Invalid response! Plese try again."
197
+ response = nil
198
+ end
199
+ end
200
+ end
201
+
177
202
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waggit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.011
4
+ version: 0.0.012
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mere Agency
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-10-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A way of integrating LocomotiveCMS/Wagon with git. This is under development
14
14
  and not ready for active use.