mortar 0.15.23 → 0.15.24

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
@@ -14,6 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require "fileutils"
17
18
  require "vendor/mortar/uuid"
18
19
  require "mortar/helpers"
19
20
  require "set"
@@ -290,8 +291,17 @@ module Mortar
290
291
  end
291
292
 
292
293
  def ensure_embedded_project_mirror_exists(mirror_dir, git_organization)
293
- # create and initialize mirror git repo if it doesn't already exist
294
- unless File.directory? mirror_dir
294
+ mirror_dir_git_dir = File.join(mirror_dir, '.git')
295
+
296
+ # create and initialize mirror git repo
297
+ # if it doesn't already exist with data
298
+ unless (File.directory? mirror_dir_git_dir) &&
299
+ (! Dir.glob(File.join(mirror_dir_git_dir, "*")).empty?)
300
+
301
+ # remove any existing data from mirror dir
302
+ FileUtils.rm_rf(mirror_dir)
303
+
304
+ # create parent dir if it doesn't already exist
295
305
  unless File.directory? mortar_mirrors_dir
296
306
  FileUtils.mkdir_p mortar_mirrors_dir
297
307
  end
@@ -16,5 +16,5 @@
16
16
 
17
17
  module Mortar
18
18
  # see http://semver.org/
19
- VERSION = "0.15.23"
19
+ VERSION = "0.15.24"
20
20
  end
@@ -352,6 +352,61 @@ STASH
352
352
  end
353
353
  end
354
354
 
355
+ it "recreates an empty mirror directory" do
356
+ with_embedded_project do |p|
357
+ mirror_dir = File.join(Dir.tmpdir, "mortar", "test-git-mirror")
358
+ FileUtils.rm_rf(mirror_dir)
359
+
360
+ # only create top-level directory, but don't add contents.
361
+ # this can happen when tmp is cleaned
362
+ project_mirror_dir = File.join(mirror_dir, p.name)
363
+ FileUtils.mkdir_p(project_mirror_dir)
364
+
365
+ mock(@git).mortar_mirrors_dir.any_times { mirror_dir }
366
+
367
+ mock(@git).git.with_any_args.any_times { true }
368
+ mock(@git).remotes.with_any_args.any_times { {"origin"=> "git@github.com:mortarcode-dev/4dbbd83cae8d5bf8a4000000_#{p.name}.git"} }
369
+ mock(@git).clone.with_any_args.times(1) { FileUtils.mkdir("#{mirror_dir}/#{p.name}") }
370
+ mock(@git).push_with_retry.with_any_args.times(3) { true }
371
+ mock(@git).is_clean_working_directory? { false }
372
+ mock(@git).did_stash_changes?.with_any_args.any_times { false }
373
+ mock(@git).branches.any_times { "master" }
374
+ mock(@git).all_branches.any_times { "master\nremotes/mortar/master" }
375
+
376
+ @git.sync_embedded_project(p, "master", "mortarcode-dev")
377
+
378
+ File.directory?(mirror_dir).should be_true
379
+ FileUtils.rm_rf(mirror_dir)
380
+ end
381
+ end
382
+
383
+ it "recreates an empty mirror .git directory" do
384
+ with_embedded_project do |p|
385
+ mirror_dir = File.join(Dir.tmpdir, "mortar", "test-git-mirror")
386
+ FileUtils.rm_rf(mirror_dir)
387
+
388
+ # create .git directory in project, but make it empty
389
+ project_mirror_dit_dir = File.join(mirror_dir, p.name, ".git")
390
+ FileUtils.mkdir_p(project_mirror_dit_dir)
391
+
392
+ mock(@git).mortar_mirrors_dir.any_times { mirror_dir }
393
+
394
+ mock(@git).git.with_any_args.any_times { true }
395
+ mock(@git).remotes.with_any_args.any_times { {"origin"=> "git@github.com:mortarcode-dev/4dbbd83cae8d5bf8a4000000_#{p.name}.git"} }
396
+ mock(@git).clone.with_any_args.times(1) { FileUtils.mkdir("#{mirror_dir}/#{p.name}") }
397
+ mock(@git).push_with_retry.with_any_args.times(3) { true }
398
+ mock(@git).is_clean_working_directory? { false }
399
+ mock(@git).did_stash_changes?.with_any_args.any_times { false }
400
+ mock(@git).branches.any_times { "master" }
401
+ mock(@git).all_branches.any_times { "master\nremotes/mortar/master" }
402
+
403
+ @git.sync_embedded_project(p, "master", "mortarcode-dev")
404
+
405
+ File.directory?(mirror_dir).should be_true
406
+ FileUtils.rm_rf(mirror_dir)
407
+ end
408
+ end
409
+
355
410
  it "syncs files to the project mirror" do
356
411
  with_embedded_project do |p|
357
412
  mirror_dir = File.join(Dir.tmpdir, "mortar", "test-git-mirror")
@@ -359,7 +414,9 @@ STASH
359
414
  mock(@git).mortar_mirrors_dir.any_times { mirror_dir }
360
415
 
361
416
  project_mirror_dir = File.join(mirror_dir, p.name)
362
- FileUtils.mkdir_p(project_mirror_dir)
417
+ project_mirror_git_dir = File.join(project_mirror_dir, ".git")
418
+ FileUtils.mkdir_p(project_mirror_git_dir)
419
+ FileUtils.touch(File.join(project_mirror_git_dir, "index"))
363
420
  FileUtils.touch("#{p.root_path}/pigscripts/calydonian_boar.pig")
364
421
 
365
422
  mock(@git).git.with_any_args.any_times { true }
@@ -385,7 +442,9 @@ STASH
385
442
  mock(@git).mortar_mirrors_dir.any_times { mirror_dir }
386
443
 
387
444
  project_mirror_dir = File.join(mirror_dir, p.name)
388
- FileUtils.mkdir_p(project_mirror_dir)
445
+ project_mirror_git_dir = File.join(project_mirror_dir, ".git")
446
+ FileUtils.mkdir_p(project_mirror_git_dir)
447
+ FileUtils.touch(File.join(project_mirror_git_dir, "index"))
389
448
  FileUtils.cp_r(Dir.glob("#{p.root_path}/*"), project_mirror_dir)
390
449
  FileUtils.touch("#{project_mirror_dir}/pigscripts/calydonian_boar.pig")
391
450
 
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: 13
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 15
9
- - 23
10
- version: 0.15.23
9
+ - 24
10
+ version: 0.15.24
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mortar Data
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-08-12 00:00:00 Z
18
+ date: 2014-08-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rdoc
@@ -41,12 +41,12 @@ dependencies:
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- hash: 53
44
+ hash: 51
45
45
  segments:
46
46
  - 0
47
47
  - 8
48
- - 5
49
- version: 0.8.5
48
+ - 6
49
+ version: 0.8.6
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency