mortar 0.15.30 → 0.15.31

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.
data/lib/mortar/git.rb CHANGED
@@ -203,6 +203,7 @@ module Mortar
203
203
  def ensure_valid_mortar_project_manifest()
204
204
  if File.exists? project_manifest_name
205
205
  ensure_luigiscripts_in_project_manifest()
206
+ ensure_gitignore_in_project_manifest()
206
207
  add_newline_to_file(project_manifest_name)
207
208
  else
208
209
  create_mortar_project_manifest('.')
@@ -221,6 +222,17 @@ module Mortar
221
222
  end
222
223
  end
223
224
 
225
+ # Ensure that the .gitignore file is included
226
+ # in every project manifest to prevent syncing
227
+ # ignored files.
228
+ #
229
+ def ensure_gitignore_in_project_manifest
230
+ gitignore_path = ".gitignore"
231
+ if File.exists? gitignore_path
232
+ add_entry_to_mortar_project_manifest(project_manifest_name, gitignore_path)
233
+ end
234
+ end
235
+
224
236
  #
225
237
  # Create a project manifest file
226
238
  #
@@ -237,6 +249,11 @@ module Mortar
237
249
  if File.directory? "#{path}/luigiscripts"
238
250
  manifest.puts "luigiscripts"
239
251
  end
252
+
253
+ if File.exists? "#{path}/.gitignore"
254
+ manifest.puts ".gitignore"
255
+ end
256
+
240
257
  end
241
258
  end
242
259
 
@@ -10,4 +10,5 @@ lib
10
10
  luigiscripts
11
11
  macros
12
12
  pigscripts
13
- udfs
13
+ udfs
14
+ .gitignore
@@ -16,5 +16,5 @@
16
16
 
17
17
  module Mortar
18
18
  # see http://semver.org/
19
- VERSION = "0.15.30"
19
+ VERSION = "0.15.31"
20
20
  end
@@ -139,6 +139,77 @@ module Mortar
139
139
  end
140
140
 
141
141
  context "project manifest" do
142
+ it "adds .gitignore if the file exists and manifest does not have it" do
143
+ with_git_initialized_project do |p|
144
+ # ensure gitignore exists
145
+ gitignore_path = File.join(p.root_path, ".gitignore")
146
+ unless File.exists? gitignore_path
147
+ write_file(gitignore_path, "luigiscripts/client.cfg\n")
148
+ end
149
+
150
+ # remove it from manifest
151
+ manifest_without_gitignore = <<-MANIFEST0
152
+ lib
153
+ macros
154
+ pigscripts
155
+ udfs
156
+ luigiscripts
157
+ MANIFEST0
158
+ manifest_path = File.join(p.root_path, "project.manifest")
159
+ write_file(manifest_path, manifest_without_gitignore)
160
+
161
+ project_manifest_before = File.open(manifest_path, "r").read
162
+ project_manifest_before.include?(".gitignore").should be_false
163
+
164
+ @git.ensure_gitignore_in_project_manifest()
165
+
166
+ project_manifest_after = File.open(manifest_path, "r").read
167
+ project_manifest_after.should == <<-MANIFEST0AFTER
168
+ lib
169
+ macros
170
+ pigscripts
171
+ udfs
172
+ luigiscripts
173
+ .gitignore
174
+ MANIFEST0AFTER
175
+ end
176
+ end
177
+
178
+ it "does not add .gitignore if the file does not exist" do
179
+ with_git_initialized_project do |p|
180
+ # ensure gitignore path does not exist
181
+ gitignore_path = File.join(p.root_path, ".gitignore")
182
+ if File.exists? gitignore_path
183
+ FileUtils.rm_rf(gitignore_path)
184
+ end
185
+
186
+ # remove it from manifest
187
+ manifest_without_gitignore = <<-MANIFEST1
188
+ lib
189
+ macros
190
+ pigscripts
191
+ udfs
192
+ luigiscripts
193
+ MANIFEST1
194
+ manifest_path = File.join(p.root_path, "project.manifest")
195
+ write_file(manifest_path, manifest_without_gitignore)
196
+
197
+ project_manifest_before = File.open(manifest_path, "r").read
198
+ project_manifest_before.include?(".gitignore").should be_false
199
+
200
+ @git.ensure_gitignore_in_project_manifest()
201
+
202
+ project_manifest_after = File.open(manifest_path, "r").read
203
+ project_manifest_after.should == <<-MANIFEST1AFTER
204
+ lib
205
+ macros
206
+ pigscripts
207
+ udfs
208
+ luigiscripts
209
+ MANIFEST1AFTER
210
+ end
211
+ end
212
+
142
213
  it "adds luigiscripts if the directory exists and manifest does not have it" do
143
214
  with_git_initialized_project do |p|
144
215
  # ensure luigiscripts path exists
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 15
9
- - 30
10
- version: 0.15.30
9
+ - 31
10
+ version: 0.15.31
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mortar Data