diff --git a/features/update.feature b/features/update.feature index fcae620a..f03142e0 100644 --- a/features/update.feature +++ b/features/update.feature @@ -28,7 +28,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files added:\s+ + Files added: test """ Given I run `cat modules/puppet-test/test` @@ -89,7 +89,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files changed:\s+ + Files changed: +diff --git a/Gemfile b/Gemfile """ Given I run `cat modules/puppet-test/Gemfile` @@ -124,7 +124,7 @@ Feature: update When I run `msync update --noop` Then the output should not match: """ - Files changed:\s+ + Files changed: +diff --git a/Gemfile b/Gemfile """ And the output should match: @@ -138,6 +138,38 @@ Feature: update source 'https://rubygems.org' """ + Scenario: Setting an existing file to deleted + Given a file named "managed_modules.yml" with: + """ + --- + - puppet-test + """ + And a file named "modulesync.yml" with: + """ + --- + namespace: maestrodev + git_base: https://github.com/ + """ + And a file named "config_defaults.yml" with: + """ + --- + Gemfile: + delete: true + """ + And a directory named "moduleroot" + And a file named "moduleroot/Gemfile" with: + """ + source '<%= @configs['gem_source'] %>' + """ + When I run `msync update --noop` + Then the output should match: + """ + Files changed: + diff --git a/Gemfile b/Gemfile + deleted file mode 100644 + """ + And the exit status should be 0 + Scenario: Setting a directory to unmanaged Given a file named "managed_modules.yml" with: """ @@ -207,7 +239,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files added:\s+ + Files added: spec/spec_helper.rb """ Given I run `cat modules/puppet-test/spec/spec_helper.rb` @@ -287,7 +319,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files added:\s+ + Files added: spec/spec_helper.rb """ @@ -306,9 +338,7 @@ Feature: update And a directory named "moduleroot" When I run `msync update --noop` Then the exit status should be 0 - And the output should not match /Files changed\s+/ - And the output should not match /Files added\s+/ - And the output should not match /Files deleted\s+/ + And the output should not match /diff/ Scenario: When specifying configurations in managed_modules.yml Given a file named "managed_modules.yml" with: @@ -338,7 +368,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files added:\s+ + Files added: test """ Given I run `cat modules/puppet-test/test` @@ -373,7 +403,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files added:\s+ + Files added: test """ Given I run `cat modules/puppet-test/test` @@ -409,7 +439,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files added:\s+ + Files added: test """ Given I run `cat modules/puppet-test/test` @@ -495,7 +525,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files added:\s+ + Files added: test """ Given I run `cat modules/puppet-test/.git/config` @@ -529,7 +559,7 @@ Feature: update Then the exit status should be 0 And the output should match: """ - Files changed:\s+ + Files changed: +diff --git a/README.md b/README.md """ Given I run `cat modules/puppet-test/README.md` diff --git a/lib/modulesync.rb b/lib/modulesync.rb index 7bf65c2f..916c0a28 100644 --- a/lib/modulesync.rb +++ b/lib/modulesync.rb @@ -72,13 +72,13 @@ def self.manage_file(filename, settings, options) module_name = settings.additional_settings[:puppet_module] configs = settings.build_file_configs(filename) if configs['delete'] - Renderer.remove(module_file(options['project_root'], module_name, filename)) + Renderer.remove(module_file(options[:project_root], module_name, filename)) else templatename = local_file(options[:configs], filename) begin erb = Renderer.build(templatename) template = Renderer.render(erb, configs) - Renderer.sync(template, "#{options[:project_root]}/#{module_name}/#{filename}") + Renderer.sync(template, module_file(options[:project_root], module_name, filename)) rescue STDERR.puts "Error while rendering #{filename}" raise diff --git a/lib/modulesync/git.rb b/lib/modulesync/git.rb index 2bbbd023..713d2137 100644 --- a/lib/modulesync/git.rb +++ b/lib/modulesync/git.rb @@ -154,12 +154,12 @@ def self.update_noop(name, options) repo = ::Git.open("#{options[:project_root]}/#{name}") repo.branch(options[:branch]).checkout - puts 'Files changed: ' + puts 'Files changed:' repo.diff('HEAD', '--').each do |diff| puts diff.patch end - puts 'Files added: ' + puts 'Files added:' untracked_unignored_files(repo).each do |file, _| puts file end