modulesync 0.6.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1dd5e56a7370a3eb358c9a6d1fdf28aab8078ba9
4
+ data.tar.gz: 444ba255257e89d604065e066978f028d798907d
5
+ SHA512:
6
+ metadata.gz: fa110f5ccfaa83e13be484e0d443cbddc50b97706dda6fa9b6080bb9bf509fbff0ecc7953dfd1014b40bae0baf5a5c214d49ec96cb640b5a1b1d13269cf51d8c
7
+ data.tar.gz: 8629e474f0b8998f5707954204a37ab94006d056640f2f438bca92fa6c4694238e7a4657281c8c2d0bf35c810da5fb26176da0da5a3e77472fb242743fb3063c
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ tmp/
2
2
  modules/
3
3
  *.gem
4
4
  Gemfile.lock
5
+ .bundle/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=documentation
@@ -0,0 +1,16 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 1.9
5
+ Exclude:
6
+ - 'vendor/**/*'
7
+ - 'tmp/**/*'
8
+ - 'pkg/**/*'
9
+
10
+ # we still support ruby 1.8
11
+ Style/HashSyntax:
12
+ Enabled: false
13
+
14
+ # dealbreaker:
15
+ Style/TrailingCommaInLiteral:
16
+ Enabled: false
@@ -0,0 +1,75 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-10-07 12:25:07 -0700 using RuboCop version 0.34.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ Lint/UselessAssignment:
11
+ Exclude:
12
+ - 'lib/modulesync.rb'
13
+ - 'lib/modulesync/cli.rb'
14
+
15
+ # Offense count: 6
16
+ Metrics/AbcSize:
17
+ Max: 64
18
+
19
+ # Offense count: 1
20
+ # Configuration parameters: CountComments.
21
+ Metrics/ClassLength:
22
+ Max: 105
23
+
24
+ # Offense count: 4
25
+ Metrics/CyclomaticComplexity:
26
+ Max: 13
27
+
28
+ # Offense count: 29
29
+ # Configuration parameters: AllowURI, URISchemes.
30
+ Metrics/LineLength:
31
+ Max: 319
32
+
33
+ # Offense count: 8
34
+ # Configuration parameters: CountComments.
35
+ Metrics/MethodLength:
36
+ Max: 79
37
+
38
+ # Offense count: 1
39
+ # Configuration parameters: CountComments.
40
+ Metrics/ModuleLength:
41
+ Max: 140
42
+
43
+ # Offense count: 4
44
+ Metrics/PerceivedComplexity:
45
+ Max: 16
46
+
47
+ # Offense count: 9
48
+ # Configuration parameters: Exclude.
49
+ Style/Documentation:
50
+ Exclude:
51
+ - 'lib/modulesync.rb'
52
+ - 'lib/modulesync/cli.rb'
53
+ - 'lib/modulesync/constants.rb'
54
+ - 'lib/modulesync/git.rb'
55
+ - 'lib/modulesync/hook.rb'
56
+ - 'lib/modulesync/renderer.rb'
57
+ - 'lib/modulesync/util.rb'
58
+
59
+ # Offense count: 1
60
+ Style/EachWithObject:
61
+ Exclude:
62
+ - 'lib/modulesync/util.rb'
63
+
64
+ # Offense count: 1
65
+ # Configuration parameters: MinBodyLength.
66
+ Style/GuardClause:
67
+ Exclude:
68
+ - 'lib/modulesync/cli.rb'
69
+
70
+ # Offense count: 1
71
+ # Cop supports --auto-correct.
72
+ # Configuration parameters: AllowAsExpressionSeparator.
73
+ Style/Semicolon:
74
+ Exclude:
75
+ - 'lib/modulesync/util.rb'
@@ -2,8 +2,24 @@
2
2
  sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
5
8
  script: 'bundle exec rake test'
6
9
  rvm:
7
10
  - 1.9.3
8
11
  - 2.0
9
12
  - 2.1
13
+ - 2.2
14
+ - 2.3.3
15
+ - 2.4.0
16
+ deploy:
17
+ provider: rubygems
18
+ api_key:
19
+ secure: "Tbf1EbLEobIIox+fftJZADZsfQQ6kl0urcMNetK7NJzFo/negD/WyJIUj3kro/B7buyYADEjTui/JR4o8EPbugfM3ie5vYOd5k3AesSzbdr4BSwGe/cGbGOB7/PZuGfFLkb94/FiCU2mIwibkbh1rHWGlBoPj7ntL0+5ZtdvsM4="
20
+ gem: modulesync
21
+ on:
22
+ rvm: 2.4.0
23
+ tags: true
24
+ all_branches: true
25
+ repo: voxpupuli/modulesync
@@ -1,4 +1,42 @@
1
- ##2015-08-13 - 0.6.1
1
+ # Changelog
2
+
3
+ ## 2017-02-13 - 0.7.2
4
+
5
+ Fixes an issue releasing 0.7.1, no functional changes.
6
+
7
+ ## 2017-02-13 - 0.7.1
8
+
9
+ Fixes an issue releasing 0.7.0, no functional changes.
10
+
11
+ ## 2017-02-13 - 0.7.0
12
+
13
+ ### Summary
14
+
15
+ This is the first release from Vox Pupuli, which has taken over maintenance of
16
+ modulesync.
17
+
18
+ #### Features
19
+ - New `msync update` arguments:
20
+ - `--git-base` to override `git_base`, e.g. for read-only git clones
21
+ - `-s` to skip the current module and continue on error
22
+ - `-x` for a negative filter (blacklist) of modules not to update
23
+ - Add `-a` argument to `msync hook` to pass additional arguments
24
+ - Add `:git_base` and `:namespace` data to `@configs` hash
25
+ - Allow `managed_modules.yml` to list modules with a different namespace
26
+ - Entire directories can be listed with `unmanaged: true`
27
+
28
+ #### Refactoring
29
+ - Replace CLI optionparser with thor
30
+
31
+ #### Bugfixes
32
+ - Fix git 1.8.0 compatibility, detecting when no files are changed
33
+ - Fix `delete: true` feature, now deletes files correctly
34
+ - Fix handling of `:global` config entries, not interpreted as a path
35
+ - Fix push without force to remote branch when no files have changed (#102)
36
+ - Output template name when ERB rendering fails
37
+ - Remove extraneous whitespace in `--noop` output
38
+
39
+ ## 2015-08-13 - 0.6.1
2
40
 
3
41
  ### Summary
4
42
 
@@ -27,7 +65,7 @@ This release adds two new flags to help modulesync better integrate with CI tool
27
65
 
28
66
  - Added tests
29
67
 
30
- ##2015-06-30 - 0.5.0
68
+ ## 2015-06-30 - 0.5.0
31
69
 
32
70
  ### Summary
33
71
 
@@ -37,7 +75,7 @@ This release adds the ability to sync a non-bare local git repo.
37
75
 
38
76
  - Allow one to sync non-bare local git repository
39
77
 
40
- ##2015-06-24 - 0.4.0
78
+ ## 2015-06-24 - 0.4.0
41
79
 
42
80
  ### Summary
43
81
 
@@ -53,7 +91,7 @@ config.
53
91
 
54
92
  - Fix markdown syntax in README
55
93
 
56
- ##2015-03-12 - 0.3.0
94
+ ## 2015-03-12 - 0.3.0
57
95
 
58
96
  ### Summary
59
97
 
@@ -87,14 +125,14 @@ number of new flags for updating modules.
87
125
  - Fix non-master branch functionality
88
126
  - Add workarounds for older git versions
89
127
 
90
- ##2014-11-16 - 0.2.0
128
+ ## 2014-11-16 - 0.2.0
91
129
 
92
130
  ### Summary
93
131
 
94
132
  This release adds the --filter flag to filter what modules to sync.
95
133
  Also fixes the README to document the very important -m flag.
96
134
 
97
- ##2014-9-29 - 0.1.0
135
+ ## 2014-9-29 - 0.1.0
98
136
 
99
137
  ### Summary
100
138
 
data/Gemfile CHANGED
@@ -1,3 +1,8 @@
1
1
  source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2
2
 
3
+ if ENV['TRAVIS_RUBY_VERSION'] && ENV['TRAVIS_RUBY_VERSION'] == '1.9.3'
4
+ gem 'json_pure', '~> 1.0'
5
+ gem 'rubocop', '< 0.42.0'
6
+ end
7
+
3
8
  gemspec
data/README.md CHANGED
@@ -265,13 +265,22 @@ pre_commit_script: openstack-commit-msg-hook.sh
265
265
 
266
266
  #### Filtering Repositories
267
267
 
268
- If you only want to sync some of the repositories in your managed_modules.yml, use the -f flag to filter by a regex:
268
+ If you only want to sync some of the repositories in your managed_modules.yml, use the `-f` flag to filter by a regex:
269
269
 
270
270
  ```
271
- msync update -f augeas -m "Commit message"
271
+ msync update -f augeas -m "Commit message" # acts only on the augeas module
272
272
  msync update -f puppet-a..o "Commit message"
273
273
  ```
274
274
 
275
+ If you want to skip syncing some of the repositories in your managed_modules.yml, use the `-x` flag to filter by a regex:
276
+
277
+ ```
278
+ msync update -x augeas -m "Commit message" # acts on all modules except the augeas module
279
+ msync update -x puppet-a..o "Commit message"
280
+ ```
281
+
282
+ If no `-f` is specified, all repository are processed, if no `-x` is specified no repository is skipped. If a repository matches both `-f` and `-x` it is skipped.
283
+
275
284
  #### Pushing to a different remote branch
276
285
 
277
286
  If you want to push the modified branch to a different remote branch, you can use the -r flag:
@@ -337,6 +346,16 @@ current date, bumped (minor) version, and commit message.
337
346
  If `CHANGELOG.md` is absent in the repository, nothing will happen.
338
347
 
339
348
 
349
+ #### Defining templates
350
+
351
+ As commented, files within moduleroot directory can be flat files or ERB templates. These files have direct access to @configs hash, which gets values from config_defaults.yml file and from the module being processed:
352
+
353
+ ```
354
+ <%= @configs[:git_base] %>
355
+ <%= @configs[:namespace] %>
356
+ <%= @configs[:puppet_module] %>
357
+ ```
358
+
340
359
  The Templates
341
360
  -------------
342
361
 
data/Rakefile CHANGED
@@ -1,11 +1,21 @@
1
1
  require 'rake/clean'
2
2
  require 'cucumber/rake/task'
3
+ require 'rubocop/rake_task'
3
4
 
4
- CLEAN.include("pkg/", "tmp/")
5
+ begin
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ rescue LoadError
9
+ puts 'rspec not installed - skipping unit test task setup'
10
+ end
11
+
12
+ RuboCop::RakeTask.new
13
+
14
+ CLEAN.include('pkg/', 'tmp/')
5
15
 
6
16
  Cucumber::Rake::Task.new do |t|
7
- t.cucumber_opts = ""
8
- t.cucumber_opts << "--format pretty"
17
+ t.cucumber_opts = ''
18
+ t.cucumber_opts << '--format pretty'
9
19
  end
10
20
 
11
- task :test => [:clean, :cucumber]
21
+ task :test => [:clean, :spec, :cucumber, :rubocop]
data/bin/msync CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  lib = File.expand_path('../../lib', __FILE__)
4
- $:.unshift(lib) unless $:.include?(lib)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
- require 'modulesync'
6
+ require 'modulesync/cli'
7
7
 
8
- ModuleSync.run(ARGV)
8
+ ModuleSync::CLI::Base.start(ARGV)
@@ -0,0 +1,18 @@
1
+ Feature: CLI
2
+ ModuleSync needs to have a robust command line interface
3
+
4
+ Scenario: When passing no arguments to the msync command
5
+ When I run `msync`
6
+ And the output should match /Commands:/
7
+
8
+ Scenario: When passing invalid arguments to the msync update command
9
+ When I run `msync update`
10
+ And the output should match /No value provided for required option/
11
+
12
+ Scenario: When passing invalid arguments to the msync hook command
13
+ When I run `msync hook`
14
+ And the output should match /Commands:/
15
+
16
+ Scenario: When running the help subcommand
17
+ When I run `msync help`
18
+ And the output should match /Commands:/
@@ -0,0 +1,28 @@
1
+ Feature: hook
2
+ ModuleSync needs to update git pre-push hooks
3
+
4
+ Scenario: Activating a hook
5
+ Given a directory named ".git/hooks"
6
+ When I run `msync hook activate`
7
+ Then the exit status should be 0
8
+ Given I run `cat .git/hooks/pre-push`
9
+ Then the output should contain "bash"
10
+
11
+ Scenario: Deactivating a hook
12
+ Given a file named ".git/hooks/pre-push" with:
13
+ """
14
+ git hook
15
+ """
16
+ When I run `msync hook deactivate`
17
+ Then the exit status should be 0
18
+ Then the file ".git/hooks/pre-push" should not exist
19
+
20
+ Scenario: Activating a hook with arguments
21
+ Given a directory named ".git/hooks"
22
+ When I run `msync hook activate -a '--foo bar --baz quux' -b master`
23
+ Then the exit status should be 0
24
+ Given I run `cat .git/hooks/pre-push`
25
+ Then the output should match:
26
+ """
27
+ "\$message" -n puppetlabs -b master --foo bar --baz quux
28
+ """
@@ -0,0 +1,24 @@
1
+ Given 'a mocked git configuration' do
2
+ steps %(
3
+ Given a mocked home directory
4
+ And I run `git config --global user.name Test`
5
+ And I run `git config --global user.email test@example.com`
6
+ )
7
+ end
8
+
9
+ Given 'a remote module repository' do
10
+ steps %(
11
+ Given a directory named "sources"
12
+ And I run `git clone https://github.com/maestrodev/puppet-test sources/puppet-test`
13
+ And a file named "managed_modules.yml" with:
14
+ """
15
+ ---
16
+ - puppet-test
17
+ """
18
+ )
19
+ write_file('modulesync.yml', <<-EOS)
20
+ ---
21
+ namespace: sources
22
+ git_base: file://#{expand_path('.')}/
23
+ EOS
24
+ end
@@ -26,11 +26,15 @@ Feature: update
26
26
  """
27
27
  When I run `msync update --noop`
28
28
  Then the exit status should be 0
29
- And the output should match /Files added:\s+test/
29
+ And the output should match:
30
+ """
31
+ Files added:
32
+ test
33
+ """
30
34
  Given I run `cat modules/puppet-test/test`
31
35
  Then the output should contain "aruba"
32
36
 
33
- Scenario: Adding a new file into foobar project-root
37
+ Scenario: Adding a file that ERB can't parse
34
38
  Given a file named "managed_modules.yml" with:
35
39
  """
36
40
  ---
@@ -51,13 +55,40 @@ Feature: update
51
55
  And a directory named "moduleroot"
52
56
  And a file named "moduleroot/test" with:
53
57
  """
54
- <%= @configs['name'] %>
58
+ <% @configs.each do |c| -%>
59
+ <%= c['name'] %>
60
+ <% end %>
61
+ """
62
+ When I run `msync update --noop`
63
+ Then the exit status should be 1
64
+
65
+ Scenario: Using skip_broken option with invalid files
66
+ Given a file named "managed_modules.yml" with:
67
+ """
68
+ ---
69
+ - puppet-test
70
+ """
71
+ And a file named "modulesync.yml" with:
72
+ """
73
+ ---
74
+ namespace: maestrodev
75
+ git_base: https://github.com/
76
+ """
77
+ And a file named "config_defaults.yml" with:
78
+ """
79
+ ---
80
+ test:
81
+ name: aruba
55
82
  """
56
- When I run `msync update --noop --project-root=foobar`
83
+ And a directory named "moduleroot"
84
+ And a file named "moduleroot/test" with:
85
+ """
86
+ <% @configs.each do |c| -%>
87
+ <%= c['name'] %>
88
+ <% end %>
89
+ """
90
+ When I run `msync update --noop -s`
57
91
  Then the exit status should be 0
58
- And the output should match /Files added:\s+test/
59
- Given I run `cat foobar/puppet-test/test`
60
- Then the output should contain "aruba"
61
92
 
62
93
  Scenario: Modifying an existing file
63
94
  Given a file named "managed_modules.yml" with:
@@ -86,7 +117,7 @@ Feature: update
86
117
  Then the exit status should be 0
87
118
  And the output should match:
88
119
  """
89
- Files changed:\s+
120
+ Files changed:
90
121
  +diff --git a/Gemfile b/Gemfile
91
122
  """
92
123
  Given I run `cat modules/puppet-test/Gemfile`
@@ -95,6 +126,164 @@ Feature: update
95
126
  source 'https://somehost.com'
96
127
  """
97
128
 
129
+ Scenario: Modifying an existing file and committing the change
130
+ Given a mocked git configuration
131
+ And a remote module repository
132
+ And a file named "config_defaults.yml" with:
133
+ """
134
+ ---
135
+ Gemfile:
136
+ gem_source: https://somehost.com
137
+ """
138
+ And a directory named "moduleroot"
139
+ And a file named "moduleroot/Gemfile" with:
140
+ """
141
+ source '<%= @configs['gem_source'] %>'
142
+ """
143
+ When I run `msync update -m "Update Gemfile" -r test`
144
+ Then the exit status should be 0
145
+ Given I cd to "sources/puppet-test"
146
+ And I run `git checkout test`
147
+ Then the file "Gemfile" should contain:
148
+ """
149
+ source 'https://somehost.com'
150
+ """
151
+
152
+ Scenario: Setting an existing file to unmanaged
153
+ Given a file named "managed_modules.yml" with:
154
+ """
155
+ ---
156
+ - puppet-test
157
+ """
158
+ And a file named "modulesync.yml" with:
159
+ """
160
+ ---
161
+ namespace: maestrodev
162
+ git_base: https://github.com/
163
+ """
164
+ And a file named "config_defaults.yml" with:
165
+ """
166
+ ---
167
+ Gemfile:
168
+ unmanaged: true
169
+ """
170
+ And a directory named "moduleroot"
171
+ And a file named "moduleroot/Gemfile" with:
172
+ """
173
+ source '<%= @configs['gem_source'] %>'
174
+ """
175
+ When I run `msync update --noop`
176
+ Then the output should not match:
177
+ """
178
+ Files changed:
179
+ +diff --git a/Gemfile b/Gemfile
180
+ """
181
+ And the output should match:
182
+ """
183
+ Not managing Gemfile in puppet-test
184
+ """
185
+ And the exit status should be 0
186
+ Given I run `cat modules/puppet-test/Gemfile`
187
+ Then the output should contain:
188
+ """
189
+ source 'https://rubygems.org'
190
+ """
191
+
192
+ Scenario: Setting an existing file to deleted
193
+ Given a file named "managed_modules.yml" with:
194
+ """
195
+ ---
196
+ - puppet-test
197
+ """
198
+ And a file named "modulesync.yml" with:
199
+ """
200
+ ---
201
+ namespace: maestrodev
202
+ git_base: https://github.com/
203
+ """
204
+ And a file named "config_defaults.yml" with:
205
+ """
206
+ ---
207
+ Gemfile:
208
+ delete: true
209
+ """
210
+ And a directory named "moduleroot"
211
+ And a file named "moduleroot/Gemfile" with:
212
+ """
213
+ source '<%= @configs['gem_source'] %>'
214
+ """
215
+ When I run `msync update --noop`
216
+ Then the output should match:
217
+ """
218
+ Files changed:
219
+ diff --git a/Gemfile b/Gemfile
220
+ deleted file mode 100644
221
+ """
222
+ And the exit status should be 0
223
+
224
+ Scenario: Setting a non-existent file to deleted
225
+ Given a file named "managed_modules.yml" with:
226
+ """
227
+ ---
228
+ - puppet-test
229
+ """
230
+ And a file named "modulesync.yml" with:
231
+ """
232
+ ---
233
+ namespace: maestrodev
234
+ git_base: https://github.com/
235
+ """
236
+ And a file named "config_defaults.yml" with:
237
+ """
238
+ ---
239
+ doesntexist_file:
240
+ delete: true
241
+ """
242
+ And a directory named "moduleroot"
243
+ When I run `msync update -m 'deletes a file that doesnt exist!' -f puppet-test`
244
+ And the exit status should be 0
245
+
246
+ Scenario: Setting a directory to unmanaged
247
+ Given a file named "managed_modules.yml" with:
248
+ """
249
+ ---
250
+ - puppetlabs-apache
251
+ """
252
+ And a file named "modulesync.yml" with:
253
+ """
254
+ ---
255
+ namespace: puppetlabs
256
+ git_base: https://github.com/
257
+ """
258
+ And a file named "config_defaults.yml" with:
259
+ """
260
+ ---
261
+ spec:
262
+ unmanaged: true
263
+ """
264
+ And a directory named "moduleroot/spec"
265
+ And a file named "moduleroot/spec/spec_helper.rb" with:
266
+ """
267
+ some spec_helper fud
268
+ """
269
+ And a directory named "modules/puppetlabs-apache/spec"
270
+ And a file named "modules/puppetlabs-apache/spec/spec_helper.rb" with:
271
+ """
272
+ This is a fake spec_helper!
273
+ """
274
+ When I run `msync update --offline`
275
+ Then the output should contain:
276
+ """
277
+ Not managing spec/spec_helper.rb in puppetlabs-apache
278
+ """
279
+ And the exit status should be 0
280
+ Given I run `cat modules/puppetlabs-apache/spec/spec_helper.rb`
281
+ Then the output should contain:
282
+ """
283
+ This is a fake spec_helper!
284
+ """
285
+ And the exit status should be 0
286
+
98
287
  Scenario: Adding a new file in a new subdirectory
99
288
  Given a file named "managed_modules.yml" with:
100
289
  """
@@ -124,7 +313,7 @@ Feature: update
124
313
  Then the exit status should be 0
125
314
  And the output should match:
126
315
  """
127
- Files added:\s+
316
+ Files added:
128
317
  spec/spec_helper.rb
129
318
  """
130
319
  Given I run `cat modules/puppet-test/spec/spec_helper.rb`
@@ -132,24 +321,210 @@ Feature: update
132
321
  """
133
322
  require 'puppetlabs_spec_helper/module_helper'
134
323
  """
135
- When I run `msync update --offline --noop`
324
+
325
+ Scenario: Updating offline
326
+ Given a file named "managed_modules.yml" with:
327
+ """
328
+ ---
329
+ - puppet-test
330
+ """
331
+ And a file named "modulesync.yml" with:
332
+ """
333
+ ---
334
+ namespace: maestrodev
335
+ git_base: https://github.com/
336
+ """
337
+ And a file named "config_defaults.yml" with:
338
+ """
339
+ ---
340
+ spec/spec_helper.rb:
341
+ require:
342
+ - puppetlabs_spec_helper/module_helper
343
+ """
344
+ And a file named "moduleroot/spec/spec_helper.rb" with:
345
+ """
346
+ <% @configs['require'].each do |required| -%>
347
+ require '<%= required %>'
348
+ <% end %>
349
+ """
350
+ When I run `msync update --offline`
351
+ Then the exit status should be 0
352
+ And the output should not match /Files (changed|added|deleted):/
353
+
354
+ Scenario: Pulling a module that already exists in the modules directory
355
+ Given a file named "managed_modules.yml" with:
356
+ """
357
+ ---
358
+ - puppet-test
359
+ """
360
+ And a file named "modulesync.yml" with:
361
+ """
362
+ ---
363
+ git_base: https://github.com/
364
+ """
365
+ And a file named "config_defaults.yml" with:
366
+ """
367
+ ---
368
+ spec/spec_helper.rb:
369
+ require:
370
+ - puppetlabs_spec_helper/module_helper
371
+ """
372
+ And a file named "moduleroot/spec/spec_helper.rb" with:
373
+ """
374
+ <% @configs['require'].each do |required| -%>
375
+ require '<%= required %>'
376
+ <% end %>
377
+ """
378
+ Given I run `git init modules/puppet-test`
379
+ Given a file named "modules/puppet-test/.git/config" with:
380
+ """
381
+ [core]
382
+ repositoryformatversion = 0
383
+ filemode = true
384
+ bare = false
385
+ logallrefupdates = true
386
+ ignorecase = true
387
+ precomposeunicode = true
388
+ [remote "origin"]
389
+ url = https://github.com/maestrodev/puppet-test.git
390
+ fetch = +refs/heads/*:refs/remotes/origin/*
391
+ """
392
+ When I run `msync update --noop`
136
393
  Then the exit status should be 0
137
394
  And the output should match:
138
395
  """
139
- Files added:\s+
396
+ Files added:
140
397
  spec/spec_helper.rb
141
398
  """
142
- When I run `msync update --offline`
399
+
400
+ Scenario: When running update with no changes
401
+ Given a file named "managed_modules.yml" with:
402
+ """
403
+ ---
404
+ - puppet-test
405
+ """
406
+ And a file named "modulesync.yml" with:
407
+ """
408
+ ---
409
+ namespace: maestrodev
410
+ git_base: https://github.com/
411
+ """
412
+ And a directory named "moduleroot"
413
+ When I run `msync update --noop`
414
+ Then the exit status should be 0
415
+ And the output should not match /diff/
416
+
417
+ Scenario: When specifying configurations in managed_modules.yml
418
+ Given a file named "managed_modules.yml" with:
419
+ """
420
+ ---
421
+ puppet-test:
422
+ module_name: test
423
+ """
424
+ And a file named "modulesync.yml" with:
425
+ """
426
+ ---
427
+ namespace: maestrodev
428
+ git_base: https://github.com/
429
+ """
430
+ And a file named "config_defaults.yml" with:
431
+ """
432
+ ---
433
+ test:
434
+ name: aruba
435
+ """
436
+ And a directory named "moduleroot"
437
+ And a file named "moduleroot/test" with:
438
+ """
439
+ <%= @configs['name'] %>
440
+ """
441
+ When I run `msync update --noop`
442
+ Then the exit status should be 0
443
+ And the output should match:
444
+ """
445
+ Files added:
446
+ test
447
+ """
448
+ Given I run `cat modules/puppet-test/test`
449
+ Then the output should contain "aruba"
450
+
451
+ Scenario: When specifying configurations in managed_modules.yml and using a filter
452
+ Given a file named "managed_modules.yml" with:
453
+ """
454
+ ---
455
+ puppet-blacksmith:
456
+ puppet-test:
457
+ module_name: test
458
+ """
459
+ And a file named "modulesync.yml" with:
460
+ """
461
+ ---
462
+ namespace: maestrodev
463
+ git_base: https://github.com/
464
+ """
465
+ And a file named "config_defaults.yml" with:
466
+ """
467
+ ---
468
+ test:
469
+ name: aruba
470
+ """
471
+ And a directory named "moduleroot"
472
+ And a file named "moduleroot/test" with:
473
+ """
474
+ <%= @configs['name'] %>
475
+ """
476
+ When I run `msync update --noop -f puppet-test`
477
+ Then the exit status should be 0
478
+ And the output should match:
479
+ """
480
+ Files added:
481
+ test
482
+ """
483
+ Given I run `cat modules/puppet-test/test`
484
+ Then the output should contain "aruba"
485
+ And a directory named "modules/puppet-blacksmith" should not exist
486
+
487
+ Scenario: When specifying configurations in managed_modules.yml and using a negative filter
488
+ Given a file named "managed_modules.yml" with:
489
+ """
490
+ ---
491
+ puppet-blacksmith:
492
+ puppet-test:
493
+ module_name: test
494
+ """
495
+ And a file named "modulesync.yml" with:
496
+ """
497
+ ---
498
+ namespace: maestrodev
499
+ git_base: https://github.com/
500
+ """
501
+ And a file named "config_defaults.yml" with:
502
+ """
503
+ ---
504
+ test:
505
+ name: aruba
506
+ """
507
+ And a directory named "moduleroot"
508
+ And a file named "moduleroot/test" with:
509
+ """
510
+ <%= @configs['name'] %>
511
+ """
512
+ When I run `msync update --noop -x puppet-blacksmith`
143
513
  Then the exit status should be 0
144
514
  And the output should match:
145
515
  """
516
+ Files added:
517
+ test
146
518
  """
519
+ Given I run `cat modules/puppet-test/test`
520
+ Then the output should contain "aruba"
521
+ And a directory named "modules/puppet-blacksmith" should not exist
147
522
 
148
523
  Scenario: Updating a module with a .sync.yml file
149
524
  Given a file named "managed_modules.yml" with:
150
525
  """
151
526
  ---
152
- - puppetlabs-stdlib
527
+ - puppet-test
153
528
  """
154
529
  And a file named "modulesync.yml" with:
155
530
  """
@@ -169,33 +544,122 @@ Feature: update
169
544
  require '<%= required %>'
170
545
  <% end %>
171
546
  """
172
- And a file named "moduleroot/.travis.yml" with:
173
- """
174
- ---
175
- sudo: false
176
- language: ruby
177
- cache: bundler
178
- bundler_args: --without system_tests
179
- script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--color --format documentation'"
180
- matrix:
181
- fast_finish: true
182
- include:
183
- - rvm: 1.8.7
184
- env: PUPPET_GEM_VERSION="~> 3.0"
185
- - rvm: 1.9.3
186
- env: PUPPET_GEM_VERSION="~> 3.0"
187
- - rvm: 2.1.5
188
- env: PUPPET_GEM_VERSION="~> 3.0"
189
- - rvm: 2.1.5
190
- env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
191
- - rvm: 2.1.6
192
- env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
193
- notifications:
194
- email: false
547
+ Given I run `git init modules/puppet-test`
548
+ Given a file named "modules/puppet-test/.git/config" with:
549
+ """
550
+ [core]
551
+ repositoryformatversion = 0
552
+ filemode = true
553
+ bare = false
554
+ logallrefupdates = true
555
+ ignorecase = true
556
+ precomposeunicode = true
557
+ [remote "origin"]
558
+ url = https://github.com/maestrodev/puppet-test.git
559
+ fetch = +refs/heads/*:refs/remotes/origin/*
560
+ """
561
+ Given a file named "modules/puppet-test/.sync.yml" with:
562
+ """
563
+ ---
564
+ spec/spec_helper.rb:
565
+ unmanaged: true
195
566
  """
196
567
  When I run `msync update --noop`
197
568
  Then the exit status should be 0
198
569
  And the output should match:
199
570
  """
200
- Not managing spec/spec_helper.rb in puppetlabs-stdlib
571
+ Not managing spec/spec_helper.rb in puppet-test
572
+ """
573
+
574
+ Scenario: Module with custom namespace
575
+ Given a file named "managed_modules.yml" with:
576
+ """
577
+ ---
578
+ - puppet-test
579
+ - electrical/puppet-lib-file_concat
580
+ """
581
+ And a file named "modulesync.yml" with:
582
+ """
583
+ ---
584
+ namespace: maestrodev
585
+ git_base: https://github.com/
586
+ """
587
+ And a file named "config_defaults.yml" with:
588
+ """
589
+ ---
590
+ test:
591
+ name: aruba
592
+ """
593
+ And a directory named "moduleroot"
594
+ And a file named "moduleroot/test" with:
595
+ """
596
+ <%= @configs['name'] %>
201
597
  """
598
+ When I run `msync update --noop`
599
+ Then the exit status should be 0
600
+ And the output should match:
601
+ """
602
+ Files added:
603
+ test
604
+ """
605
+ Given I run `cat modules/puppet-test/.git/config`
606
+ Then the output should contain "url = https://github.com/maestrodev/puppet-test.git"
607
+ Given I run `cat modules/puppet-lib-file_concat/.git/config`
608
+ Then the output should contain "url = https://github.com/electrical/puppet-lib-file_concat.git"
609
+
610
+ Scenario: Modifying an existing file with values expoxed by the module
611
+ Given a file named "managed_modules.yml" with:
612
+ """
613
+ ---
614
+ - puppet-test
615
+ """
616
+ And a file named "modulesync.yml" with:
617
+ """
618
+ ---
619
+ namespace: maestrodev
620
+ git_base: https://github.com/
621
+ """
622
+ And a file named "config_defaults.yml" with:
623
+ """
624
+ ---
625
+ README.md:
626
+ """
627
+ And a directory named "moduleroot"
628
+ And a file named "moduleroot/README.md" with:
629
+ """
630
+ echo '<%= @configs[:git_base] + @configs[:namespace] %>'
631
+ """
632
+ When I run `msync update --noop`
633
+ Then the exit status should be 0
634
+ And the output should match:
635
+ """
636
+ Files changed:
637
+ +diff --git a/README.md b/README.md
638
+ """
639
+ Given I run `cat modules/puppet-test/README.md`
640
+ Then the output should contain:
641
+ """
642
+ echo 'https://github.com/maestrodev'
643
+ """
644
+
645
+ Scenario: Running the same update twice and pushing to a remote branch
646
+ Given a mocked git configuration
647
+ And a remote module repository
648
+ And a file named "config_defaults.yml" with:
649
+ """
650
+ ---
651
+ Gemfile:
652
+ gem_source: https://somehost.com
653
+ """
654
+ And a directory named "moduleroot"
655
+ And a file named "moduleroot/Gemfile" with:
656
+ """
657
+ source '<%= @configs['gem_source'] %>'
658
+ """
659
+ When I run `msync update -m "Update Gemfile" -r test`
660
+ Then the exit status should be 0
661
+ Given I remove the directory "modules"
662
+ When I run `msync update -m "Update Gemfile" -r test`
663
+ Then the exit status should be 0
664
+ Then the output should not contain "error"
665
+ Then the output should not contain "rejected"